在Python中获取字符串长度,然后将该int转换为字节数组的正确方法是什么?将其打印到控制台进行测试的正确方法是什么?
最佳答案
使用struct .
import struct
print struct.pack('L', len("some string")) # int to a (long) byte array
关于.net - IronPython - 将 int 转换为字节数组,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/796197/