首页 > 解决方案 > Python check number is less than

问题描述

if uservar[0][0] == text_hashed:
                sql = "SELECT expires FROM akeys WHERE user = %s"
                var = (message.author.id,)
                mycursor.execute(sql, var)
                myresultrank = mycursor.fetchall()
                guild = client.get_guild(CENSORED)

                if myresultrank < 1:
                    print("Less")
                else:
                    print("Normal")

                sql = """UPDATE akeys SET user = %s WHERE license = %s"""
                val = (message.author.id, text_hashed)
                mycursor.execute(sql, val)
                mydb.commit()

Im trying to check if the number in the data base is less than 1 but i get this error

await coro(*args, **kwargs)
File "My Path", line 529, in 
on_message
if myresultrank < 1:
TypeError: '<' not supported between instances of 'list' and 'int'

标签: pythondiscorddiscord.py

解决方案


试试这些改变

                myresultrank = mycursor.fetchone()

. . .

                if myresultrank[0] < 1:


推荐阅读