字符串反编译
百思不得其解,搜了很多资料,耗费了很长时间,弄出来了
1.今天遇到一道题:把下边字典里值用中文显示出来
{'word': '\xE5\x95\x8A\xE5\x95\x8A\xE5\x95\x8A\xE5\x95\x8A\xE5\x95\x8A\xE5\x95\x8A'}
# data = {'word': '\xE5\x95\x8A\xE5\x95\x8A\xE5\x95\x8A\xE5\x95\x8A\xE5\x95\x8A\xE5\x95\x8A'} # new_data = data['word'] # print(new_data.encode().decode('unicode-escape').encode('latin1').decode('utf-8'))
2.上边的弄出来了, 'xE7xADx89xE4xBDxA0xE5x8Cx85xE5x85xBBxE6x88x91' 用上边的方法是否能弄出来呢?
a = 'xE7xADx89xE4xBDxA0xE5x8Cx85xE5x85xBBxE6x88x91' print(a.encode().decode('unicode-escape').encode('latin1').decode('utf-8'))
结果:
C:UsersAdministratorAppDataLocalProgramsPythonPython36-32python.exe F:/安装包/moduile_three/服务端.py
çä½ å
å
Ⱦ
Process finished with exit code 0
显然是不行的,乱码,又弄了很长时间,经人指点
a = 'xE7xADx89xE4xBDxA0xE5x8Cx85xE5x85xBBxE6x88x91' b = a.encode('raw_unicode_escape').decode('utf-8') print(b) 结果: C:UsersAdministratorAppDataLocalProgramsPythonPython36-32python.exe F:/安装包/moduile_three/服务端.py 等你包养我 Process finished with exit code 0
哇塞!!!还有这操作,突然觉得自己太low了~继续学习....