从CSV格式文件中读入数据
fo=open(fname)
ls=[ ]
for line in fo:
line=line.replace("\n"," ")
ls.append(line.split(","))
fo.close()
将数据写入CSV
ls=[[ ],[ ],[ ]]
f=open(fname,'w')
for item in ls:
f.write(','.join(item)+'\n')
f.close()
采用二层循环逐一处理
for row in ls:
for column in row:
print(column)