Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Administrator
/
lesson11_2
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
caf46cda
authored
Jul 20, 2022
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
auto save
parent
bfd9a984
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
3 deletions
__pycache__/func.cpython-37.pyc
dmeo.py
func.py
__pycache__/func.cpython-37.pyc
0 → 100644
View file @
caf46cda
File added
dmeo.py
0 → 100644
View file @
caf46cda
import
func
data
=
func
.
new_input
()
# 模块名称.函数名称()
result
=
func
.
amont
(
data
)
print
(
"总金额是:"
,
result
)
func.py
View file @
caf46cda
...
@@ -6,8 +6,25 @@ def new_input():
...
@@ -6,8 +6,25 @@ def new_input():
if
unit
==
'q'
:
if
unit
==
'q'
:
break
break
else
:
else
:
total
.
append
(
unit
)
try
:
unit
=
int
(
unit
)
except
:
print
(
"请输入整数!"
)
else
:
total
.
append
(
int
(
unit
))
print
(
total
)
print
(
total
)
return
total
# return 返回total给调用
# 调用函数
# 调用函数
new_input
()
price_list
=
new_input
()
# price_list 是接收函数返回值
def
amont
(
money
):
# 形式参数只是在定义函数时写上
sm
=
0
for
i
in
money
:
sm
+=
i
return
sm
result
=
amont
(
price_list
)
# 调整用函数时,要根据"形式参数"个数来赋值"实际参数"
print
(
"总金额是:"
,
result
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment