Python3分别将list、numpy数组、变量内容写入txt文件中

亲测可用

初学python,还不是很了解,其实只要用str() 将数字(如int)包住即可,本身是str型的不需要str() 将数字包住

如下:

0、file.write(str(12));

1、python保存numpy数据:

1

numpy.savetxt("result.txt", numpy_data)

2、保存list数据:

1

2

3

扫描二维码关注公众号,回复: 6755662 查看本文章

file=open('data.txt','w'

file.write(str(list_data)); 

file.close() 

猜你喜欢

转载自blog.csdn.net/yimixgg/article/details/90598407