我正在尝试在python中表示一个函数。
功能是:
(x^2)-(y+1)^2
pow()函数不能接受字符串作为参数。
我已尝试以此方式表示它:
math.pow(x,2)- math.pow(y+1,2)
但出现错误:
TypeError: must be real number, not str
有没有办法在python中做到这一点?
将x
和y
转换为int
(或float
,如果适用)。
math.pow(int(x), 2) - math.pow(int(y) + 1, 2)