import csv fo = open("result.txt", "w+") reader = csv.reader(open('test.csv')) for line in reader: Name = line[0] fo.writelines(['class ',Name,'{\n']) fo.writelines('};\n') fo.close() 来源:https://www.cnblogs.com/rednodel/p/11359020.html 标签 csv fo line python