无法从python脚本中显示正确的中文单词
Python代码
import subprocess
import re
strCmdResult = subprocess.Popen("curl -vvv 'http://xxxx.xxxx.xxxx/xxxx/xxxx.js?r=0071563892276000' -H 'Referer: http://xxx.xxx.xxx'", shell=True, stdout=subprocess.PIPE).stdout.read()
print strCmdResult输出
rq[56]="1739907^1^11^45^▒▒▒▒▒Ρ▒~▒▒▒▒^27633,24230^▒ڶ▒▒▒ϣ▒▒▒▒Ŭ▒▒ŵ▒▒▒▒^6687323^";发布于 2019-07-24 12:54:33
该文件似乎是由gbk或gb18030 编码编码的。
两者都为该特定行生成此输出:
“1732948^1^1^85^洛迪高阿古利(助攻:A.華倫西亞)^84828^洛迪高阿古利(助攻:A.瓦伦西亚)^6687325^25000”
为中国人列出的其他编码没有对数据进行解码。
你可以这样解码:
strCmdResult = subprocess.Popen("curl -vvv 'http://xxx.xxxx.xxx/xxxx/xxx.js?r=0071563892276000' -H 'Referer: http://xxxx.xxx.xxx'", shell=True, stdout=subprocess.PIPE).stdout.read()
decoded = strCmdResult.decode('gbk')
print decodedhttps://stackoverflow.com/questions/57181038
复制相似问题