首先上下比较发现,js中escape后的字符串与Unicode编码很相似
%u4eba%u751f%u82e6%u77ed
\u4eba\u751f\u82e6\u77ed
所以得出以下解决方法,可以将js中escape后的字符串转成utf-8
import urllib.parse
escape_str = '%u4eba%u751f%u82e6%u77ed'
str1 = escape_str.replace('%u', '\\u')
# 得到结果 str1 = '\u4eba\u751f\u82e6\u77ed'
str = str1.encode('utf-8').decode('unicode_escape')
# 得到结果str = ‘人生苦短’