Commit 528894e6 by BellCodeEditor

save project

parent 4c464139
Showing with 21 additions and 34 deletions
def new_input(): filel=open(r'D:\LYQ/testf.txt','w',encoding='utf-8')
total=[] filel.write('小李:10本\n')
while True: filel.write('晓丽:12本\n')
unit = input('伞兵,你要吃什么(q退出)') filel.write('小丽:8本\n')
if unit == 'q': filel.write('小利:7本\n')
break filel.close()
else: \ No newline at end of file
try:
unit = int(unit)
except:
print('请重新输入,')
else:
total.append(unit)
finally:
print('============================')
return total
def sum(money):
count = 0
for i in money:
count = count + i
return count
price = new_input()
pay = sum(price)
print('您一共消费了' + str(pay) + '元.扫码还是现金?' )
\ No newline at end of file
try: new_data=''
age = int(input('你今年几岁')) with open(r'D:\LYQ/testf.txt','r',encoding='utf-8') as filel:
except: for data in filel:
print('要输入整数啊') if '小李:10本' in data:
else: print('小李数据在文件中')
if age<18: data=data.replace('小李:10本','小李:11本')
print('不可以喝酒噢') new_data += data
print('程序结束~')
\ No newline at end of file with open(r'D:\LYQ/testf.txt','w',encoding='utf-8') as filel:
filel.write(new_data)
with open(r'D:\LYQ/testf.txt','r',encoding='utf-8') as filel:
a=filel.read()
print(a)
\ 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