Commit d57ec22c by BellCodeEditor

auto save

parent 5ec53ebb
Showing with 25 additions and 0 deletions
file2 = open(r"C:\Users\XNBC\Desktop\古诗.txt",'w',encoding='utf-8')
file2.write("蓝田日暖玉生烟\n")
file2.write("蓝田日暖玉生烟\n")
file2.write("蓝田日暖玉生烟\n")
file2.write("蓝田日暖玉生烟\n")
file2.write("蓝田日暖玉生烟\n")
file2.write("此情可待成追忆")
file2.close()
\ No newline at end of file
file1 = open(r"c:\Users\XNBC\Documents\lesson13-1\sales_list.txt",'r',encoding='utf-8')
a = file1.readlines()
finall = []
for i in a:
data = i.split()
sum = 0
for j in data[1:]:
sum = sum + int(j)
result = data[0] + str(sum) + '\n'
finall.append(result)
file1.close()
file2 = open(r"C:\Users\XNBC\Desktop\new_list.txt",'w',encoding='utf-8')
file2.writelines(finall)
file2.close()
\ 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