我有一个包含(我相信)拉丁1编码的文件。在
但是,我无法将regex与此文件匹配。在
如果我搜索文件,它看起来很好: 在
但是,我找不到字符串:
In [12]: txt = open("b").read()
In [13]: print txt
<Vw_IncidentPipeline_Report>
In [14]: txt
Out[14]: '\x00 \x00 \x00<\x00V\x00w\x00_\x00I\x00n\x00c\x00i\x00d\x00e\x00n\x00t\x00P\x00i\x00p\x00e\x00l\x00i\x00n\x00e\x00_\x00R\x00e\x00p\x00o\x00r\x00t\x00>\x00\r\x00\n'
In [22]: txt.find("Vw_IncidentPipeline_Report")
Out[22]: -1
In [23]: txt.decode("latin-1")
Out[23]: u'\x00 \x00 \x00<\x00V\x00w\x00_\x00I\x00n\x00c\x00i\x00d\x00e\x00n\x00t\x00P\x00i\x00p\x00e\x00l\x00i\x00n\x00e\x00_\x00R\x00e\x00p\x00o\x00r\x00t\x00>\x00\r\x00\n'
In [25]: txt.decode("utf-16le")
Out[25]: u'\u2000\u2000\u3c00\u5600\u7700\u5f00\u4900\u6e00\u6300\u6900\u6400\u6500\u6e00\u7400\u5000\u6900\u7000\u6500\u6c00\u6900\u6e00\u6500\u5f00\u5200\u6500\u7000\u6f00\u7200\u7400\u3e00\u0d00\u0a00'
如何成功解码字符串,以便在其中找到字符串?在
你的编码错误。尝试
txt.decode("UTF-16BE")
让我们检查一下iconv。。。在
不,那里没有日本人
不是拉丁语-1,是utf-16大端音:
所以,就这样破译,从此过上幸福的生活吧;—)。在
可能是UTF-8。你的正则表达式是什么?在
相关问题 更多 >
编程相关推荐