2 回答

TA贡献1872条经验 获得超3个赞
我正在创建一个基本程序,该程序将使用GUI来获取商品的价格,如果初始价格小于10,则从价格中减去10%,如果初始价格为10,则从价格中减去20%。大于十:
import easygui
price=easygui.enterbox("What is the price of the item?")
if float(price) < 10:
easygui.msgbox("Your new price is: $"(float(price) * 0.1))
elif float(price) > 10:
easygui.msgbox("Your new price is: $"(float(price) * 0.2))
我仍然收到此错误:
easygui.msgbox("Your new price is: $"(float(price) * 0.1))
TypeError: 'str' object is not callable`
为什么会出现此错误?

TA贡献1821条经验 获得超6个赞
这部分 :
"Your new price is: $"(float(price)
要求python调用此字符串:
"Your new price is: $"
就像您将要使用的函数一样: function( some_args)
它将始终触发错误:
TypeError: 'str' object is not callable
添加回答
举报