数组转换为字符串写入文件中

import numpy
X = numpy.array([1, 2, 3, 4])
str = ' '.join(str(j) for j in X)
with open('X.txt', 'w+') as f:
    f.write(str+'\n')

发布了34 篇原创文章 · 获赞 3 · 访问量 1305

猜你喜欢

转载自blog.csdn.net/weixin_43486780/article/details/104757015