我有一个从requests.get恢复的 JSON 文件
这是我的一些 JSON:
[{"order":{"id":"B4589B26","status_order_id":5,"status_order_name":"Sent","customer_id":326
"order_products":[{"order_product":{"id":96218,"order_id":96538,"product_id":59320,}}],"customer_email":"user@gmail.com","customer_company":"SARL","customer_name":"user user", .....
Run Code Online (Sandbox Code Playgroud)
这是我的代码:
token = "xxxx"
r = requests.get('url', auth=('user@gmail.com', token))
mydb = pymysql.connect(host='localhost',
user='root',
passwd='user',
db='ytm_db')
cursor = mydb.cursor()
data = r.json()
json_obj = json.loads(r)
for ord in json_obj["order"]:
print("id:", ord["id"])
print("status_id:", ord["status_order_id"])
print('---')
cursor.execute("INSERT INTO table_test (id, status_order_id, customer_id) VALUES (%s,%s,%s)", (ord["id"], ord["status_order_id"], ord["customer_id"]))
#close the connection to the database.
mydb.commit()
cursor.close()
print ("Done")
Run Code Online (Sandbox Code Playgroud)
我有这个错误:
'not {!r}'.format(s.__class__.__name__))
TypeError: the JSON object must be str, bytes or bytearray, not 'Response'
Run Code Online (Sandbox Code Playgroud) I know this question has been asked several times, I tried to find a solution but I found nothing. I am trying to create a graph chart.js.
the part that contains the error is that of 'option:', because when I delete it all works well, but despite that I check well, I do not find the error
here is my error:
Uncaught SyntaxError: Unexpected identifier
Run Code Online (Sandbox Code Playgroud)
here is my script:
<script>
var timeFormat = 'MM/DD/YYYY HH:mm:ss';
function newDateLabel(dateObject) { …Run Code Online (Sandbox Code Playgroud)