Commit 1ea4b569 by BellCodeEditor

save project

parent 9169a693
Showing with 20 additions and 24 deletions
def new_input():
total = []
while True:
unit=input("请输入:")
if unit== 'q':
break
else:
try:
unit=int(unit)
except:
print("请您输入整数。")
else:
total.append(unit)
return total
def som(m):
c=0
for i in m:
c=c+i
return c
p=new_input()
b=som(p)
print(b)
\ No newline at end of file
sell = open(r"C:\Users\23636\Desktop\nmb.sbbssb","w",encoding="ucf-8") as sell:
sell.write('帅比:10本\n')
sell.write('坤坤:12本\n')
sell.close()
\ No newline at end of file
# sell = open(r"C:\Users\23636\Desktop\smzsmz.txt","w",encoding="utf-8")
# sell.write('帅比:10本\n')
# sell.write('坤坤:12本\n')
# sell.close()
with open(r"C:\Users\23636\Desktop\smzsmz.txt","r",encoding="utf-8") as sell:
for data in sell:
if "小强:10本" in data:
print("小强数据在文件")
if "小兰:12本" in data:
print("小兰数据在文件")
\ 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