我收到这个错误
类型错误
Traceback (most recent call last)
<ipython-input-7-995aa3052f74> in <module>()
A,B,C,D = 200, 48.475, 0.0026, 400
---> y_true = sigmoide(x, A, B, C, D)
<ipython-input-7-995aa3052f74> in sigmoide(x, A, B, C, D)
"""4PL sigmoide equation."""
---> return A*erf((x-B)/C*sqrt(2)) + D
TypeError: unsupported operand type(s) for -: '_io.TextIOWrapper' and 'float'
当我尝试运行此代码时:
^{pr2}$请帮忙解决这个错误吗?谢谢!在
将
x
定义为打开的文件:但不是从文件中读取数据,而是调用
^{pr2}$sigmoide
函数并将打开的文件作为第一个参数传递!在在函数内部,继续尝试从打开的文件中计算减法!在
这当然行不通——Python不知道如何从打开的文件中减去一个数字!然后得到
unsupported operand type(s)
错误。在非常感谢大家!在
@Const:你刚才提到的错误是因为我打开x和y的meas文件时,它们是脚本而不是float。以下是我解决错误的代码:
相关问题 更多 >
编程相关推荐