如何将tkinter刻度数字放入txt文件?

2024-10-01 02:29:53 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着把秤上的数字输入一个txt文件。 但是有一个错误。我粘贴的代码在一个类中,只是发布了相关信息

将命令放入pythons内置文件操作的写入部分

self.spawnrate_scale = Scale(from_=10, to=2000, orient=HORIZONTAL, label="Spawn Rate",)
self.spawnrate_scale.grid(row=0, column=1)

self.spawnrate_button = Button(text="Apply", command=self.spawnsetting)
self.spawnrate_button.grid(row=1, column=1)


spawnfile = open("carspawnspeed","w")
spawnfile.write(self.spawnrate_scale.get())
spawnfile.close()
spawnfile.write(self.spawnrate_scale.get())

TypeError:write()参数必须是str,而不是int


Tags: 文件selftxtget粘贴错误columnbutton