在Python中,我需要将一个numpy-arrays列表(见附件图片)写入一个txt.-file,然后在一个新的python-file中重用原始的数组列表。我如何才能做到这一点?
read_files = open("read_files.txt","w+")
content = str(df)
read_files.write(content)
read_files.close()
然后在新的python文件中,我这样做了:
file = open("read_files.txt", "r")
content = file.read()
但是,当我想在新的python-file中对数组列表进行切片时,我得到以下错误:
TypeError: string indices must be integers
1条答案
按热度按时间hsgswve41#
对3D阵列使用
np.save
:注意:该文件不是人类可读的。
输出: