我的.txt
文件中有很多数据。看起来像这样:
# T1 T2 T3 T4 T5 T6 T7 T8
1 20.67 20.70 20.73 20.76 20.69 20.73 20.66 20.72
2 20.68 20.70 20.74 20.75 20.69 20.73 20.66 20.72
我想找到最大/最小。使用Python脚本的值。
首先,我尝试查找T1
列的最大值。这是我的代码(非常简单):
import numpy as np
T1 = np.genfromtxt('data.txt', unpack=True)
T1_max=np.maximum(T1)
print("T1_max")
当我尝试运行它时,会收到以下错误消息:
Line #7816 (got 10 columns instead of 1)
Line #7817 (got 10 columns instead of 1)
Line #7818 (got 10 columns instead of 1)
Line #7819 (got 10 columns instead of 1)
Line #7820 (got 10 columns instead of 1)
Line #7821 (got 2 columns instead of 1)
(它从第2行开始(第10行。)。它必须是'np.genfromtxt'函数。我必须添加什么参数以使其起作用?或者您不知道如何启动替代脚本。哪个输出最大/最小值?
谁能帮我?
这里的问题不是设置8个变量。每个列一个变量。python的'max'功能也可以做到:
T1, T2, T3, T4, T5, T6, T7, T8 = np.genfromtxt('data.txt', unpack=True)
T1max = max(T1)
print(T1max)
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句