写入txt文件
with open('pkl\\xxx.txt', 'w') as ft:
print(yourname,file=ft)
ft.close()
写循环变量到txt文件
fs = open('pkl\\xxx.txt', 'a')
for j in range(k):
print(pointsInCluster[index_1], file=fs)
fs.close()
写入pkl文件(连续多次)
f = open('pkl\\xxx.pkl', 'ab')
for data in dataloader:
optimizer.zero_grad()
pickle.dump(g[0], f)
读pkl文件(多次)
fr = open('pkl\\xxx.pkl', 'rb')
for i in range(85):
data = pickle.load(fr)
data_list.append(data)
fr.close()