我有一个返回数字的函数。我将此数字添加到整数类型,但它给我一个错误,说函数返回的数字是“函数”类型。
如何将 'function' 类型转换为 'int' 类型,以便对它们执行数学函数?有没有办法让函数返回一个'int'?我在函数中尝试了以下内容,但它仍然不会返回“int”类型:
def cost_of_trip(city, days, extra):
return int(car_cost(days) + hotel(days) + transportation(city) + extra)
print cost_of_trip("Madrid", 7, 2500)
print type(cost_of_trip)
但函数仍然返回:
type 'function'