我在使用以下代码时遇到问题:
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")
Run Code Online (Sandbox Code Playgroud)
产生的错误如下:
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
Run Code Online (Sandbox Code Playgroud)
我不确定问题是什么,因为我已经将名称从温度更改为温度并在温度附近添加括号但仍然发生错误.
我目前正在尝试使用tkinter程序创建两个窗口,但它似乎没有工作.直到最近我才把我的游戏移到了tkinter,这是第一次使用tkinter.由于这一点,我不知道为什么这不起作用.
这是我的第一个窗口,它的工作正常
class Application(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.pack()
self.create_widgets()
self.crafting_listbox
Run Code Online (Sandbox Code Playgroud)
我的第二个窗口不起作用
class Application_2(tk.Frame):
def __init__(self, master=None):
super().__init__(master)
self.pack()
self.crafting_listbox()
Run Code Online (Sandbox Code Playgroud)
然后是完成位
root = tk.Tk()
app = Application(master=root)
app.mainloop()
Run Code Online (Sandbox Code Playgroud)
我不确定为什么这不起作用,哪里出错了?