Commit dae17c5a by BellCodeEditor

save project

parent 14ee9df9
Showing with 33 additions and 3 deletions
with open(r'c:\Users\admin\Desktop\大智的文件.txt','r',encoding='utf-8') as a:
b=a.readlines()
final_sum=[]
for i in b:
c=i.split()
#print(c[1:])
sum=0
for d in c[1:]:
sum=sum+int(d)
e=c[0]+str(sum)
print(e)
\ No newline at end of file
e=c[0]+str(sum)+'\n'
final_sum.append(e)
with open(r'c:\Users\admin\Desktop\大智的文件.txt','a',encoding='utf-8') as a:
a.writelines(final_sum)
\ No newline at end of file
a=['锦瑟\n','[唐]李商隐\n']
a=['锦瑟\n','[唐]李商隐\n']
c=['锦瑟无端五十弦,\n','一线一柱思华年。\n']
d=['庄生晓梦迷蝴蝶,\n','望帝春心托杜鹃。\n']
e=['沧海月明珠有泪,\n','蓝田日暖玉生烟。\n']
f=['此情可待成追忆,\n','只是当时已惘然。\n']
g=['谁打开这个文档,谁就是傻逼(作者除外)。']
#with open(r'c:\Users\admin\Desktop\大智的文件.txt','a',encoding='utf-8') as b:
#b.writelines(a)
#b.writelines(c)
#b.writelines(d)
#b.writelines(e)
#b.writelines(f)
with open(r'c:\Users\admin\Desktop\大智的文件.txt','r',encoding='utf-8') as file:
a=file.read()
# a.replace('蓝田日暖玉生烟。','____________\n')
# a.replace('此情可待成追忆。','____________\n')
print(a)
with open(r'c:\Users\admin\Desktop\大智的文件.txt','w',encoding='utf-8') as file:
# a.replace('蓝田日暖玉生烟。','____________\n')
# a.replace('此情可待成追忆。','____________\n')
print(a)
\ No newline at end of file
a=[]
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