【发布时间】:2021-02-04 03:45:21
【问题描述】:
我想从 Py2 转换这个:
with open(path, "wb") as f1:
for i in w_vectors:
print >>f1, i, " ".join(map(str, numpy.round(w_vectors[i], decimals=6)))
到 Py3:
with open(path, "wb") as f1:
for i in w_vectors:
print (f1, i, " ".join(map(str, numpy.round(w_vectors[i], decimals=6))))
f1.close()
但它不会保存到文本文件中。我做错了什么?
【问题讨论】:
-
这能回答你的问题吗? Python: Open and write to a .txt file
标签: python python-3.x python-2.x