python - 如何解码 python 中的未知编码字符串,试过 chardet?

标签 python python-2.7 encoding decoding chardet

我不知道字符串的编码类型,但我想解码该字符串。 我试过 chardet python 模块但没有用。

我知道字符串的输出,无论如何我可以使用 python 解码字符串...

例子

Input
'\x06@\t\xa6'

Output
104860070

任何帮助将不胜感激

最佳答案

它是用 struct.pack() 创建的文本,所以使用 struct.unpack()

import struct

result = struct.unpack('!i', '\x06@\t\xa6')[0]
print(result) 

# 104860070

关于python - 如何解码 python 中的未知编码字符串,试过 chardet?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41313409/

相关文章:

python - 当数据库只能通过jumphost访问时如何通过Python连接MySQL

python - 为 C 库生成 Python SWIG 绑定(bind)时 undefined symbol

express - webpack gzip 与 Express gzip

python - Beautiful Soup 无法识别 Python 3、IPython 6 控制台上的 UTF-8 编码

Python - 为什么a=1/3是int而a=0.3是float

java - 从命令行和代码设置系统属性有什么区别?

Python-验证电子邮件是否存在

python - Flask:重定向(url_for())返回html但不加载页面

python - Pandas dataframe - 将行索引值重新排列到列标题中

python - 尝试模拟对象中的方法给出 'AttributeError'