>>> import struct
>>> buf3 = 'Hello World'
>>> bin_buf3 = struct.pack('11s', buf3.encode('utf-8'))
>>> ret3 = struct.unpack('11s', bin_buf3)
>>> print(bin_buf3, ' <====> ', ret3)
python3中字符串与字节流的转换
最新推荐文章于 2024-04-24 14:29:30 发布
>>> import struct
>>> buf3 = 'Hello World'
>>> bin_buf3 = struct.pack('11s', buf3.encode('utf-8'))
>>> ret3 = struct.unpack('11s', bin_buf3)
>>> print(bin_buf3, ' <====> ', ret3)