import pymysql, json conn = pymysql.connect( host="115.159.197.235", port=13306, user="root", passwd="AtBnAWfMyCw7Jd4J", db="spider_db", charset="utf8", cursorclass=pymysql.cursors.DictCursor ) cursor = conn.cursor() sql = "SELECT id,options_json FROM special_detail_parse" cursor.execute(sql) datas = [item for item in cursor.fetchall()] for data in datas: new_data = json.loads(data['options_json']) new_data = json.dumps(new_data, ensure_ascii=False) print(data['id'], new_data) cursor.execute('UPDATE special_detail_parse SET options_json=%s WHERE id=%s', (new_data, data['id'])) conn.commit() cursor.close() conn.close()
04-17
3万+
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)