标签:for unicode body ascii height try data form format
data = json.loads(request.body)
for key in data:
try:
data[key] = data[key].encode(‘ascii‘).decode(‘unicode_escape‘)
# 针对发过来的‘\\u5e7f\\u5dde\\u5e02\\u5357\\u73e0\\u533b\\u7597\\u7f8e\\u5bb9\\u95e8\\u8bca\\u6709\\u9650\\u516c\\u53f8‘
#"\\\\u7814\\\\u4e00\\\\u65b0\\\\u80fd\\\\u6e90\\\\u7814\\\\u53d1\\\\u4e2d\\\\u5fc3\\\\u6709\\\\u9650\\\\u516c\\\\u53f8"
except UnicodeEncodeError as e:
logging.info("err: {}, merchant: {}".format(str(e), data[key]))
python web api 对接java 存在的json中文问题
标签:for unicode body ascii height try data form format
原文地址:https://www.cnblogs.com/meiriyixiaobu/p/10114124.html