Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/312.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在python上使用SQLite3时出现TypeError_Python_Sqlite - Fatal编程技术网

在python上使用SQLite3时出现TypeError

在python上使用SQLite3时出现TypeError,python,sqlite,Python,Sqlite,我正在使用money函数创建一个discord bot,我的代码正在出错 Ignoring exception in on_message Traceback (most recent call last): File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 270, in _run_event await coro(*arg

我正在使用money函数创建一个discord bot,我的代码正在出错

Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\user\AppData\Local\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 270, in _run_event
    await coro(*args, **kwargs)
  File "c:\BOT\kikibot.py", line 1050, in on_message
    ohyeah=int(cur.execute(f'SELECT money FROM USERS WHERE id={str(message.author.id)}'))+rand
TypeError: int() argument must be a string, a bytes-like object or a number, not 'sqlite3.Cursor'
我的代码是

elif message.content=='키키야 돈줘':
asdfa=cur.execute('SELECT*FROM USERS')
对于asdfa中的行:
如果第行为str(message.author.id):
等待1원부터 1000원 까지 아무 양의 돈을 줍니다', '돈 기능')
如果vip中有str(message.author.id):
等待1원부터 10000원 까지 아무 양의 돈을 줍니다', '돈 기능')
rand=random.randrange(110001)
其他:
等待1원부터 1000원 까지 아무 양의 돈을 줍니다', '돈 기능')
rand=random.randrange(11001)
ohyeah=int(cur.execute(f'selectmoneyfromsusers,其中id={str(message.author.id)}'))+rand
execute(f'updateuserssetmoney={ohyeah}其中id={str(message.author.id)})
等待makeembed(f'**{rand}**원을 줬습니다\N현재 **{message.author.display_name}**님의 돈 액수: {ohyeah}','돈 기능')
cur.commit()
返回
如果str(表[“A”+str(i)].value)==str(message.author.id):
等待1원부터 1000원 까지 아무 양의 돈을 줍니다', '돈 기능')
如果vip中有str(message.author.id):
等待1원부터 10000원 까지 아무 양의 돈을 줍니다', '돈 기능')
rand=random.randrange(110001)
其他:
等待1원부터 1000원 까지 아무 양의 돈을 줍니다', '돈 기능')
rand=random.randrange(11001)
ohyeah=int(表[C'+str(i)]值)+兰德
表[C'+str(i)]。值=“”
表[C'+str(i)]。值=str(ohyeah)
等待makeembed(f'**{rand}**원을 줬습니다\N현재 **{message.author.display_name}**님의 돈 액수: {ohyeah}','돈 기능')
标志=1
文件。保存('정보.xlsx')
等待makeembed(“`키키야 가입`을 입력해 먼저 가입을 하세요", '에러 감지 기능')
我该怎么做才能不出错


(对不起,我的英语水平很差)

导致问题的那一行是

ohyeah=int(cur.execute(f'selectmoneyfromsusers,其中id{str(message.author.id)}'))+rand
cur.execute
不会返回可强制转换为
int
的数据类型。相反,您可能希望先获取数据,然后强制该返回对象上的
int
数据类型。换句话说

cur.execute(f'selectmoneyfromsusers,其中id{str(message.author.id)}'))
money=cur.fetchall()
money=[int(x)表示货币中的x]#假设通过查询选择了多行

最后一行取决于SQL表的结构和内容,但您知道了。如果有什么不清楚的地方,我非常乐意详细说明。

一个韩国人说对不起,但我不能翻译成英语,因为他说
message.author.id
不是可以转换为int的东西,而是一个sqlite游标。