凌的博客

您现在的位置是: 首页 > 学无止境 > python > 

python

python numpy.array 转txt

2019-09-25 python 1325
import numpy as np

a = np.zeros((6, 6))
txt = []
for y in a:
    txt.append(" ".join([str(x) for x in y]))

content = "\n".join(txt)
with open("a.txt", "w+", encoding="utf-8") as f:
    f.write(content)

print(content)

2.png

文章评论

0条评论