Commit 0d0ca666 by BellCodeEditor

auto save

parent b7498cbe
Showing with 14 additions and 20 deletions
student1 = {'语文': 91, '数学': 88, '英语': 85} # 打开
student2 = {'语文': 97, '数学': 98, '英语': 90} with open(r'C:\Users\EDY\Desktop\test.txt','r',encoding='utf-8') as file:
student3 = {'语文': 95, '数学': 100, '英语': 93} # 写入
score = {'悟空': student1, '诺依': student2, '小贝': student3} new_data = ""
for data in file:
if "小强:10本" in data:
data = data.replace("10","11")
new_data += data
# 查询并打印出输入的名字对应的所有科目的成绩
while True :
name = input("名字:") # 将 new_data 写入源文件 w模式
if name in score : with open(r'C:\Users\EDY\Desktop\test.txt','w',encoding='utf-8') as file:
a = score[name] file.write(new_data)
print('*'*30) \ No newline at end of file
for k,v in a.items():
print(k,v)
break
else:
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