Commit 889c20b9 by BellCodeEditor

auto save

parent dc22b1a3
Showing with 33 additions and 0 deletions
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
file1=open(r'C:\Users\玛酷机器人\Desktop\test.txt')
#file1.write('小兰:12本\n')
#file1.write('小丽:12本\n')
#file1.write('李文:9本\n')
#file1.write('张伟:16本\n')
#file1.close()
with open(r'C:\Users\玛酷机器人\Desktop\test.txt') as file:
file.write('小强:12本\n')
file.write('李明:15本\n')
def new_input():
total=[]
while True:
money=input('请输入(q退出):')
if money=='q':
break
else:
try:
money=int(money)
except:
print('请重新输入一个数字')
else:
total.append(money)
finally:
print('-'*30)
return total
result=new_input()
print(result)
\ No newline at end of file
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