Commit 68f7c336 by BellCodeEditor

save project

parent 81f5f5f9
This diff is collapsed. Click to expand it.
new_date=""
with open(r'C:\Users\Administrator\Desktop\test.txt','r',encoding='utf-8') as filel:
for data in filel:
if '小强:10' in data:
data = data.replace("小强:10","小明12")
new_date+=data
print(new_date)
chengji=input()
ls=[]
a=0
ls.append(chengji.split())
while chengji:
chengji=input()
ls.append(chengji.split())
# 写入同学们的捐赠明细:'小兰:12本'、'小丽:11本'、'李文:9本'、'张伟:16本'
with open(r'C:\Users\Administfilelrator\Desktop\test.txt','a',encoding='utf-8') as filel:
filel.write("小强:10本")
filel.write("小明:24")
chengji=input()
ls=[]
a=0
ls.append(chengji.split())
while chengji:
chengji=input()
ls.append(chengji.split())
ls.pop(-1)
for i in ls:
a=a+int(i[1])
a=a/len(ls)
b={}
for i in ls:
b[i[0]]=i[1]
ls1=list(b.items())
ls1.sort(key=lambda x:x[1],reverse=True)
print("分数最高的学科是{}:{}分数最低的学科是{}:{}平均分是:{:.2f}".format(ls1[0][0],ls1[0][1],ls1[-1][0],ls1[-1][1],a))
with open(r"C:\Users\Administrator\Desktop\sales_list.txt","w",encoding="utf-8")as spas:
spas.write("小明")
\ 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