【发布时间】:2017-12-08 13:20:57
【问题描述】:
以下代码有问题:
if verb == "stoke":
if items["furnace"] >= 1:
print("going to stoke the furnace")
if items["coal"] >= 1:
print("successful!")
temperature += 250
print("the furnace is now " + (temperature) + "degrees!")
^this line is where the issue is occuring
else:
print("you can't")
else:
print("you have nothing to stoke")
产生的错误如下:
Traceback(most recent call last):
File "C:\Users\User\Documents\Python\smelting game 0.3.1 build
incomplete.py"
, line 227, in <module>
print("the furnace is now " + (temperature) + "degrees!")
TypeError: must be str, not int
我不确定问题出在哪里,因为我已将名称从 temp 更改为 temperature,并在 temperature 周围添加了括号,但仍然出现错误。
【问题讨论】:
标签: python python-3.6 typeerror