我无法看到这里的无效语法是什么,任何帮助都将不胜感激。
if alpha == "alpha":
updatefile('Class 1 Results.csv',0,"1")
elif Class == "2":
with open('Class 2 Results.csv', 'a') as f:
file_writer = csv.writer(f, delimiter=',',lineterminator='\n')
file_writer.writerow((name, score))sortcsv('Class 2 Results.csv', 0)
答案 0 :(得分:3)
试试这个:
if alpha == "alpha":
updatefile('Class 1 Results.csv',0,"1")
elif Class == "2":
with open('Class 2 Results.csv', 'a') as f:
file_writer = csv.writer(f, delimiter=',',lineterminator='\n')
file_writer.writerow((name, score))sortcsv('Class 2 Results.csv', 0)
正如@ poke的评论中提到的,空格在Python中很重要。这就是为什么缩进必须正确的原因 - 例如,在if
声明中,if
,elif
和else
都必须在相同级别的缩进。