1 list1 = [] 2 f = open('data.txt', mode='a', encoding='utf - 8') 3 with open('data.txt', mode='a', encoding='utf - 8'): 4 for rrr in range(1, 101): 5 list1.append((f'{rrr}\n')) 6 f.writelines(list1) 7 print(rrr) 8 f.write('') 9 f.close()
标签:encoding,python,list1,100,txt,data,rrr From: https://www.cnblogs.com/frazer-cxy-jsfx/p/17250376.html