Commit 2881c32f by BellCodeEditor

save project

parent 2de051d3
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
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
file=open(r"C:\Users\Administrator\Desktop\text.txt","w",encoding="utf-8")
file.write('小兰:12本')
file.close()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment