我正在开发一个带有货币系统的Python Twitch IRC Bot。每一分钟,我都会向用户添加一点"余额。"但是,每当我运行脚本时,我的控制台都会收到TypeError
。它说TypeError: 'int' object is not iterable
,我不知道如何解决它,我不知道问题是什么,因为它之前工作得很好。这是我的代码:
userlist = [open('userlist.txt').read()]
balances = [open('balances.txt').read()]
def loadusers():
global userlist
userlist = [map(str, userlist[0].split(", "))]
def loadbalances():
global balances
balances = [map(int, balances[0].split(", "))]
def savelist(path, listname):
with open(path, 'w') as text_file:
text_file.write(re.sub('[\'\[\]]', '', str(listname)))
loadusers()
loadbalances()
def givePoints():
num = 0
for users in balances:
balances[num] += 1
num += 1
threading.Timer(60.0, givePoints).start()
我收到balances[num] += 1
上的错误。
提前感谢您的帮助!
答案 0 :(得分:0)
解决方案:我从[map(str, userlist[0].split(", "))]
语句中删除了括号,现在它完美无缺!感谢大家的提示:)