Commit 2dedf271 by BellCodeEditor

save project

parent 7d269fd7
Showing with 11 additions and 3 deletions
with open(r'c:\Users\TH\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8')as d:
a=d.read()
print(a)
with open(r'c:\Users\TH\Documents\lesson13-1\sales_list.txt','r',encoding='utf-8')as d: #打开文件
a=d.readlines() #读取多行
for i in a: #i为每行数据 字符串
lent=i.split() #整理数据 成列表 元素之间以间隔符为分隔
r=lent[1:] #去掉索引为0的元素
sum=0
for s in r:
# print(s)
sum=int(s)+sum
print(sum)
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