Commit a93653d7 by BellCodeEditor

save project

parent 7576e165
Showing with 15 additions and 12 deletions
# 臂力挑战赛 import csv
# 快用你机灵的小脑瓜想想,如何将刘强和他的臂力值自动插入到hero列表中?
name='刘强' subjsct = ["姓名","语文","数学","英语"]
power=66 score1 = ["小贝","0","0","0"]
hero=['赵一',30,'丁二',37,'孙五',52,'王猛',89,'周亮',98] score2 = ["聪聪","95","91","95"]
# 自动排序
for i in range(len(hero)): with open("scores.csv","w",encoding="utf-8") as csvfile:
if i%2==1 and hero[i]>=power: writer = csv.writer(csvfile)
hero.insert(i-1,name) writer.writerow(subjsct)
hero.insert(i,power) writer.writerow(score1)
print(hero) writer.writerow(score2)
\ No newline at end of file \ No newline at end of file
姓名,语文,数学,英语
小贝,0,0,0
聪聪,95,91,95
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