[英]Python - Load data of .txt file and save in np.array
I'm working with the python programming language我正在使用 python 编程语言
Suppose I have a file named "data.txt", written in the format below (the text is already written in the format of np.array):假设我有一个名为“data.txt”的文件,格式如下(文本已经写成np.array的格式):
([[0.0000000, 1.0893900, 0.0000000], [0.0000000, 1.0820800, 0.0000000], [0.0000000, 1.0815400, 0.0000000]])
How could I load the information from this file and save that data in an np.array variable?如何从该文件加载信息并将该数据保存在 np.array 变量中?
What I need is something like loading the information from the txt file in the form below:我需要的是像下面的形式从 txt 文件中加载信息:
variable = np.array([[0.0000000, 1.0893900, 0.0000000], [0.0000000, 1.0820800, 0.0000000], [0.0000000, 1.0815400, 0.0000000]])
To work arround my problem, i just cleaned the "(", "[", "]", and ")" symbols and use this answer Load txt file into numpy array为了解决我的问题,我刚刚清理了“(”、“[”、“]”和“)”符号并使用这个答案将 txt 文件加载到 numpy 数组中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.