Commit 8950949c by BellCodeEditor

save project

parent 18434f76
Showing with 10 additions and 2 deletions
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
with open(r'C:\Users\DELL\Desktop\test.txt','r',encoding='utf-8') as file: with open(r'C:\Users\DELL\Desktop\test.txt','r',encoding='utf-8') as file:
a=file.readlines() a=file.readlines()
final_sum=[]
for i in a: for i in a:
data=i.split() data=i.split()
#print(data[1:]) #print(data[1:])
...@@ -11,4 +12,7 @@ for i in a: ...@@ -11,4 +12,7 @@ for i in a:
for ab in data[1:]: for ab in data[1:]:
sum=sum+int(ab) sum=sum+int(ab)
six=data[0]+str(sum) six=data[0]+str(sum)
print(six) final_sum.append(six)
\ No newline at end of file
with open(r'C:\Users\DELL\Desktop\new_test.txt','a',encoding='utf-8') as file:
file.writelines(final_sum)
\ No newline at end of file
a=['你好呀\n','悟空\n','我在贝尔学编程\n']
with open(r'C:\Users\DELL\Desktop\hello,cheems.txt','a',encoding='utf-8') as file:
file.writelines(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