【发布时间】:2017-03-11 07:29:38
【问题描述】:
我有一个名为 studentDetailsCopy 的 CSV 文件,需要在其末尾添加一行数据,但目前它会将其添加到最后一行的末尾,因此最终看起来像这样:电子邮件末尾的as 和28 是需要在其下方添加的数据(第28 行)
这是我的代码:
newStudentAttributes = ([str(lastRowInt), newSurname, newForename, newDoB, newAddress, newHomePhoneNumber, newGender, newTutorGroup, newSchoolEmail])
with open('studentDetailsCopy.csv', 'a') as studentDetailsCSV:
writer = csv.writer(studentDetailsCSV, dialect='excel')
writer.writerow(newStudentAttributes)
【问题讨论】: