我下面的代码有什么问题,错误说是不可写的
with open('F:\learning\coding\python learning\jadi excersisse\work with files\grades_for_exercise.csv') as f:
myFile=csv.reader(f)
person_mean=OrderedDict()
for row in myFile:
name=row[0]
person_grades=[]
for number in row[1:]:
person_grades.append(int(number))
person_mean[name]=mean(person_grades)
print(list(person_mean.items()))
with open ('F:\learning\coding\python learning\jadi excersisse\work with files\one_result.csv') as csvfile:
csvwriter=csv.writer(csvfile)
csvwriter.writerows((person_mean))
我需要的数据是维滕在csv文件
2条答案
按热度按时间cyvaqqii1#
据我所知,这就是如何在python中读写csv文件
我希望这对你有帮助
vq8itlhq2#
通过阅读open()函数的文档,我发现了问题,需要在open函数中写入模式,当我在文件中添加写入模式“w”时,问题就解决了。