Commit b228a69c by BellCodeEditor

auto save

parent 10af1cba
Showing with 26 additions and 3 deletions
list1=[]
with open(r"C:\Users\半半俊\Desktop\1212.txt",'r',encoding='utf-8') as f:
b=f.readlines()#读取文件数据,返回列表
for i in b[1:]:
s=0
a=i.split()
for j in a[1:]:
s=s+int(j)
ave=s/4
a.append(str(s))
a.append(str(ave))
list1.append(str(a)+'\n')
kemu=b[0].split()
kemu.append('总分')
kemu.append("平均分")
list1.insert(0,kemu)
print(list1)
# with open(r"C:\Users\半半俊\Desktop\wode1212.txt",'w',encoding='utf-8') as f1:
# f1.writelines(list1)#写入的数据必须是列表,内容必须是字符串
i = 5 # 行
j = 3 # 列
# 使用变量i和j,代替乘法算式里面的元素,打印出单个乘法算式
a="['中国','美国’,’日本’]"
a.replace('中','德')
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