Tru*_*rin -1 python sql type-conversion
我有一个返回元组的查询,我试图将第一个值从该元组转换为 int 但它总是给我这个错误:
TypeError: int() argument must be a string, a bytes-like object or a number, not 'tuple'
我不明白为什么要这样做,因为返回的值如下所示: [(25,)]
这是代码:
cursor.execute("SELECT temp FROM temperatures WHERE datetimetest = ?", [datenow])
currentTemp = cursor.fetchall()
print(currentTemp) # this gives me [(25,)]
convertedTemp = int(currentTemp[0])
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
9351 次 |
| 最近记录: |