Commit 62936396 by BellCodeEditor

save project

parent ae2e760b
Showing with 7 additions and 4 deletions
......@@ -2,8 +2,11 @@ with open (r'c:\Users\ThinkPad\Documents\lesson13-1\sales_list.txt','r',encoding
a = file1.readlines()
# print(a)
for i in a: for...in...把每一行的数据遍历
data = i.split() 把字符串切片切分成更细的一个个子富川
print(data[1:])
for i in a:
data = i.split()
sum = 0
for sales in data[1:]:
sum+=int(sales)
result = data[0]+str(sum)
print(result)
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