0
cursor.execute(f"SELECT user_id, Class, Health, Mana, Defense, Maxmana, Maxhealth, Attack, Critical FROM savefile WHERE user_id = '{message.author.id}'")
           result1 = cursor.fetchone()
           classs = int(result1[1]); health = int(result1[2]); mana = int(result1[3]); defense = int(result1[4]); attack = int(result1[7]); critical = int(result1[8])
           sql = "UPDATE savefile SET Class = ? AND SET Health = ? AND SET Mana = ? AND SET Defense = ? AND SET Maxmana = ? AND SET Maxhealth = ? AND SET Attack = ? AND SET Critical = ? WHERE user_id = ?"
           val = (classs + classplus, str(message.author.id),
                  health + healthplus, str(message.author.id),
                  mana + manaplus, str(message.author.id),
                  defense + defenseplus, str(message.author.id),
                  attack + attackplus, str(message.author.id),
                  critical + criticalplus, str(message.author.id))
           cursor.execute(sql, val)
           db.commit()

这是我正在使用的代码的一部分。我目前正在制作一个不和谐的机器人,并且有几个其他命令可以添加到一列中。但是,在上面显示的代码的第三行“classs = ...”行上,(额外的 S 是故意的)我收到此错误:

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'

一般来说,我对使用 sqlite 比较陌生,不明白为什么会这样。我的其他机器人命令中有类似的代码,但不明白为什么这特别不起作用。感谢您提前提供任何帮助!

4

1 回答 1

0

这些结果之一 (result1[i]) 很可能是 NoneType,这意味着没有从数据库中检索到数据:

classs = int(result1[1]); health = int(result1[2]); mana = int(result1[3]); defense = int(result1[4]); attack = int(result1[7]); critical = int(result1[8])
于 2020-04-05T19:20:11.430 回答