Python

python bytes concatenation

2017-01-07  本文已影响42人  戏之地

where this problem comes from

To Concatenate The Last byte of the bytes string to the end of the string

When you index with a single value (rather than a slice), you get an integer, rather than a length-one bytes instance.

Bytes Constructor Trick

bytes(20)  doesn't give you "0x14" as you think 
it's b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

How let it give you "0x14"

bytes({20})
why?
you send the constructor a set(a iterable) bytes works dealing iterable,but remember set is unorderable
上一篇下一篇

猜你喜欢

热点阅读