37,719
社区成员
发帖
与我相关
我的任务
分享
for i in edge:
fil.write('{} {}\n'.format(*i))
fil.close()
这样似乎也可以,我是新手,你可以给我解释一下为什么要变成字符串格式才能写入txt文件吗?还有
edge .to_csv('edge.csv')
with open('edge.csv','r') as f:
print(f)
这样存文件为什么也不行呢 for i in edge:
fil.write('{} {}\n'.format(*i))
fil.close()
这样似乎也可以,我是新手,你可以给我解释一下为什么要变成字符串格式才能写入txt文件吗?还有
edge .to_csv('edge.csv')
with open('edge.csv','r') as f:
print(f)
这样存文件为什么也不行呢
edge=[(1,2),(1,3)]
with open ('D:/testP/zzr.txt','w') as f:
for i in edge:
f.write(str(i[0])+' '+str(i[1])+'\n')