【问题标题】:Python - Load data of .txt file and save in np.arrayPython - 加载 .txt 文件的数据并保存在 np.array
【发布时间】:2021-03-18 03:30:15
【问题描述】:

我正在使用 python 编程语言

假设我有一个名为“data.txt”的文件,写成如下格式(文本已经写成np.array的格式):

([[0.0000000,   1.0893900,  0.0000000], [0.0000000, 1.0820800,  0.0000000], [0.0000000, 1.0815400,  0.0000000]])

如何从该文件中加载信息并将该数据保存在 np.array 变量中?

我需要的是像下面的表格从txt文件中加载信息:

variable = np.array([[0.0000000,    1.0893900,  0.0000000], [0.0000000, 1.0820800,  0.0000000], [0.0000000, 1.0815400,  0.0000000]])

【问题讨论】:

标签: python python-3.x numpy


【解决方案1】:

为了解决我的问题,我刚刚清理了“(”、“[”、“]”和“)”符号并使用这个答案Load txt file into numpy array

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-01
    • 2021-03-23
    相关资源
    最近更新 更多