【问题标题】:What does mean those kinds like "% U+R m" in hexadecimal十六进制中的“%U + R m”之类的意思是什么
【发布时间】:2020-06-18 18:01:32
【问题描述】:

我尝试用python读取mkv视频二进制读取,所以我的代码是:

a = open("vokoscreen-2019-12-21_12-15-11.mkv","rb")
a.read()

得到了很大的结果,这只是一小部分

W0I\xfb\xd4\x95l\xcfG\xa1\xa0\xb20\x9a\xb6\xa9\xbc\xa2\xdd\xc5\x9b}\x17e\xc2q\xa8d\x94\xda\x91\xd5F\xb9\xcbW2QK+p/\xc0\xd9\xf4D\x84\xda\xcb\xa7\xd42(b\r\x8f\x10\xb5\x84\xb0\x8f\xe3,\xaaf\xcfkd\xcf\xdb(}\xcf\tp\x84\xde\xb2l\xbfZ\xc8\xcc\x03+\xfe7;\x816\xa8sh] m\

我的问题是 xdb(} 中的 ( } 是什么?,这个 xcbW2QK+p 是什么?,这个 xa8sh] 中的 ] 是什么。 谢谢。

【问题讨论】:

  • 我能问一下您实际期望得到什么吗?图片列表?那部电影的剧本?你的标题提到了十六进制——你期待吗?

标签: python python-3.x hex binaryfiles hex-editors


【解决方案1】:

如果存在对应字节值的可打印 ASCII 字符,则 Python 字节文字显示,否则显示转义的十六进制值。

例如:

>>> # Inside the ASCII range but unprintable
>>> b'\x01'
b'\x01'

>>> # Inside the ASCII range and printable
>>> b'\x36'
b'6'

>>> # Outside the ASCII range
>>> b'\x91'
b'\x91'

language referencecmets:

[Bytes literals] 只能包含 ASCII 字符;数值为 128 或更大的字节必须用转义符表示。

【讨论】:

  • 谢谢,我知道 b'\x01\x59' 给了我一个结果 '\x01Y' 因为 0x01 在 ascii 表中是 [Start heading] 所以它是不可打印的,而 0x59 在 ascii 中是 Y表,它是可打印的。
  • 有没有办法获取十六进制代码而不用 ascii 中的值替换?
猜你喜欢
  • 2019-07-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-17
  • 2018-09-08
  • 2022-12-06
  • 2014-01-07
相关资源
最近更新 更多