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
2881c32f
authored
Jul 22, 2023
by
BellCodeEditor
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save project
parent
2de051d3
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
21 deletions
__pycache__/sb.cpython-37.pyc
func.py
sb.py
sb1.py
__pycache__/sb.cpython-37.pyc
0 → 100644
View file @
2881c32f
File added
func.py
View file @
2881c32f
total
=
[]
import
sb
while
True
:
unit
=
input
(
"请输入:"
)
a
=
sb
.
new_input
()
if
unit
==
'q'
:
print
(
a
)
break
b
=
sb
.
s
(
a
)
else
:
print
(
b
)
total
.
append
(
unit
)
\ No newline at end of file
print
(
total
)
\ No newline at end of file
sb.py
View file @
2881c32f
def
new_input
():
def
new_input
():
total
=
[]
list
=
[]
zong
=
0
while
True
:
while
True
:
unit
=
input
(
"请输入(退出按q):
"
)
b
=
input
(
"请输入值(退出按q)
"
)
if
unit
==
'q'
:
if
b
==
"q"
:
break
break
else
:
try
:
try
:
unit
=
int
(
unit
)
b
=
int
(
b
)
except
:
except
:
print
(
"请输入正确的价格
"
)
print
(
"输入错误!
"
)
else
:
else
:
zong
=
zong
+
unit
list
.
append
(
b
)
print
(
"总共花费"
)
return
list
def
s
(
o
):
zong
=
0
for
i
in
o
:
zong
=
zong
+
i
return
zong
return
zong
\ No newline at end of file
a
=
new_input
()
print
(
a
)
\ No newline at end of file
sb1.py
0 → 100644
View file @
2881c32f
file
=
open
(
r"C:\Users\Administrator\Desktop\text.txt"
,
"w"
,
encoding
=
"utf-8"
)
file
.
write
(
'小兰:12本'
)
file
.
close
()
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