小编Kai*_*Kai的帖子

Python3在打印十六进制值时添加了额外的字节

我遇到了Python2和Python3之间的一个奇怪的区别.使用Python3打印时,打印相同的字符列表会产生额外的字节C2.我本来期望同样的行为.Python2的行为与我预期的一样.我在这里错过了什么?

$ python3 -c "print('\x30\xA0\x04\x08')" | xxd
0000000: 30c2 a004 080a     
$ python2 -c "print('\x30\xA0\x04\x08')" | xxd
0000000: 30a0 0408 0a  
Run Code Online (Sandbox Code Playgroud)

python python-2.x python-3.x

5
推荐指数
2
解决办法
760
查看次数

标签 统计

python ×1

python-2.x ×1

python-3.x ×1