什么是“不支持的操作数类型 -:'int' 和 'tuple'"?方法? [英] What does "unsupported operand type(s) for -: 'int' and 'tuple'" means?
本文介绍了什么是“不支持的操作数类型 -:'int' 和 'tuple'"?方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到一条错误消息:
unsupported operand type(s) for -: 'int' and 'tuple'
我该如何纠正?
from scipy import integrate
cpbar = lambda T: (3.826 - (3.979e-3)*T + 24.558e-6*T**2 - 22.733e-9*T**3 + 6.963e-12*T**4)*8.314
deltahbarCH4 = integrate.quad(cpbar,298,1000)
var = deltahbarCH4
hRPbar = hRPbar + (deltahbarCO2 + 2*deltahbarH2O - var -2*deltahbarO2)
推荐答案
integrate.quad()
返回一个元组;deltahbarCO2 + 2*deltahbarH2O
是一个整数,您正在尝试减去 var
元组.
integrate.quad()
returns a tuple; deltahbarCO2 + 2*deltahbarH2O
is an integer, you are trying to subtract the var
tuple.
如果您想要只是 integrate.quad()
结果的整数 y
,请使用该元组的第一个元素:>
If you wanted just the integral y
of the integrate.quad()
result, use the first element of that tuple:
var = deltahbarCH4[0]
或使用元组赋值:
var, err = deltabarCH4
这篇关于什么是“不支持的操作数类型 -:'int' 和 'tuple'"?方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文