如何从Python中的二进制文件中读取一块字节?
我正在使用file.read(block_size)从二进制文件中读取一个字节块。这些字节输入的变量已输入< class'bytes'>。
我需要用在十六进制中表达的单字节值(例如\ x0a)中的每个字节中的每个字节。
Python的运营商是什么?
I am reading a block of bytes from a binary file using file.read(block_size). The variable that these bytes go into is typed <class 'bytes'>.
I need to XOR each byte in the stream with single byte value expressed in Hex, e.g. \x0A.
What is the operator in Python for doing this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Python的位XOR运算符是
^
编辑:
XOR操作员也可以使用十六进制数字:
Python's bitwise-XOR operator is
^
edit:
The XOR operator works with hex numbers as well: