【发布时间】:2019-12-08 21:38:02
【问题描述】:
请问这个错误是什么意思? 我有这个代码:
steps = np.loadtxt('par.in', unpack=True, usecols=[4])
maximum = np.loadtxt('par.in', unpack=True, usecols=[3])
minimum = np.loadtxt('par.in', unpack=True, usecols=[2])
a = "%0.2f" % (steps[1])
b = "%0.2f" % (maximum[1])
c = "%0.2f" % (minimum[1])
for i in np.arange (a,b,c):
x, y, chi2, chi2r = np.loadtxt('omega_'+str("%0.2f" % i), unpack=True, usecols=[0, 2, 3, 4])
错误是:
Traceback(最近一次调用最后一次):文件“program.py”, 第 34 行,在 for i in np.arange (omega_min,omega_max,omega_krok): TypeError: unsupported operand type(s) for -: 'str' and 'str'
【问题讨论】:
-
a,b,c 是字符串而不是 int 类型
-
np.arrange()期望 3 个 int 参数,你通过 3 str 代替。
标签: python formatting