Python3 execjs executes js code. Errors are reported if there are Chinese characters and escape characters in the code.

God of trouble, please take a look. Thank you

jss = """
var apps =[
  {
    "id": "13970",
    "uid": "193586",
    "title": "\u8fd0\u52a8\u6b65\u6570\u5b9d\u6b65\u6b6",
    "price": "1620.00",
    "price_max": "1980.00",
    "purchases": "121",
    "ad_support": "1",
    "wxapp_support": "2",
    "encrypt": "0",
    "createtime": "1533455964",
    "type": "1",
    "displayorder": "1",
    "price_range": "1620.00 - 1980.00",
    "is_new": true,
    "date_format": "2018-08-05",
    "month_day_format": "08.05",
    "time_format": "15:59:24",
    "username": "hudasd"
    }
];
let getDB=()=>apps;
"""
compile = js_engine.compile(jss)
res = compile.call("getDB")
print(res)
exit()


UnicodeEncodeError: "ascii" codec can"t encode characters in position 132-143: ordinal not in range(128)
Apr.11,2021

if you pass by later, you can change it into js2py, to solve the problem of Chinese bug

.
import js2py
list = js2py.eval_js(jsstr)

you can try this

import sys
reload(sys)
sys.setdefaultencoding('utf-8')

if not, take a look at your character encoding

>>>import sys
>>>sys.stdout.encoding
'UTF-8'
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e56429-453a2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e56429-453a2.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?