嗨,我正在制作一个适用于不同用户的数学程序,然后将分数写入配置文件(.ini),但问题是当我尝试这样做时,我会收到一条错误消息:
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Program Files\Python33\lib\tkinter\__init__.py", line 1475, in __call__
return self.func(*args)
File "C:\Users\Public\Documents\Programming\Math-Bot\Math-Bot.py", line 105, in check
config[user]['right'] = config[user]['right'] + int(1)
TypeError: Can't convert 'int' object to str implicitly
这是我用来决定他们的答案是对还是错的代码:
def check():
if guess.get().lower() == str(no1 + no2):
global ri
answer.set('Right!')
ri = ri + 1
right.set(ri)
config[user]['right'] = config[user]['right'] + int(1)
else:
global wa
answer.set('Wrong, It Was ' + str(no1 + no2))
wa = wa + 1
wrong.set(wa)
config[user]['wrong'] = config[user]['right'] + int(1)
无论如何我可以解决这个问题吗?
提前致谢!