【发布时间】:2021-04-19 06:58:28
【问题描述】:
当我尝试从MYSQL 检索JSON 时,为什么会出现此错误?我该如何解决?
`def get_go(order_no):
mycursor.execute("SELECT `order_details` FROM `orders` WHERE `order_no` = " + str(order_no))
myresult = mycursor.fetchall()
for x in myresult:
return json.loads(x)`
返回此错误。
文件“/usr/lib/python3.7/json/init.py”,第 341 行,加载中 raise TypeError(f'JSON对象必须是str, bytes or bytearray, ' TypeError: JSON对象必须是str, bytes or bytearray, 不是 元组
当我尝试使用
x = 'my_json_data_here'
y = json.loads(x)
它工作正常。为什么?
【问题讨论】:
-
你如何获得标记为
my_json_data_here的部分?
标签: mysql json python-3.x