可能有点绕。举例:
>>> ord('ß')
223 (大于 127 )
>>> hex(ord('ß'))
'0xdf'
>>> b'\xdf'
b'\xdf'(想要的)
>>> ord('A')
65(小于 127)
>>> hex(ord('A'))
'0x41'
>>> b'\x41'
b'A' (不是想要的)
虽然 doc 里说明了这种行为,想要结果仍为 b'\x41',不知有没有什么方法
>>> ord('ß')
223 (大于 127 )
>>> hex(ord('ß'))
'0xdf'
>>> b'\xdf'
b'\xdf'(想要的)
>>> ord('A')
65(小于 127)
>>> hex(ord('A'))
'0x41'
>>> b'\x41'
b'A' (不是想要的)
虽然 doc 里说明了这种行为,想要结果仍为 b'\x41',不知有没有什么方法