Commit 130d699b by BellCodeEditor

auto save

parent b86098f4
import csv
with open('score1.csv','r',encoding='utf-8')as f:
r=csv.reader(f) #读取文件的内容
r=list(r) #把读取到的数据转化成列表 list(变量)
pipi=r[7] #r列表的第7个索引
print('皮皮的成绩是:',pipi)
print('所有人的英语成绩')
for i in r:
print(i[3])
#单行数据导入
a=[1,2,3,4]
with open('score2.csv','w',encoding='utf-8')as f:
w=csv.writer(f) #创建读写对象
w.writerow(a) #把列表数据加入到文件中
#多行写入
b=[[4,5,6,7,8],[9,10,11,12,13],[14,15,16,17,18,19]]
with open('score3.csv','w',encoding='utf-8',newline='')as f:
w=csv.writer(f) #创建读写对象
w.writerows(b) #把列表数据加入到文件中
\ No newline at end of file
姓名,语文,数学,英语,地理,历史,政治,生物,化学,物理
小贝,99,100,94,90,88,89,96,98,96
李强,86,95,96,84,86,63,78,66,74
小依,75,88,94,54,77,97,86,77,89
聪聪,65,76,97,66,73,78,58,66,69
波奇,74,67,61,72,66,81,75,79,80
九尾,88,85,80,78,74,90,81,69,70
皮皮,77,87,83,69,90,79,71,74,69
\ No newline at end of file
4,5,6,7,8
9,10,11,12,13
14,15,16,17,18,19
姓名,语文,数学,英语,地理,历史,政治,生物,化学,物理
小贝,99,100,94,90,88,89,96,98,96
李强,86,95,96,84,86,63,78,66,74
小依,75,88,94,54,77,97,86,77,89
聪聪,65,76,97,66,73,78,58,66,69
波奇,74,67,61,72,66,81,75,79,80
九尾,88,85,80,78,74,90,81,69,70
皮皮,77,87,83,69,90,79,71,74,69
\ 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