Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何打包2个字符的数组+;2个带python的空字符';s结构?_Python_Struct_Binary - Fatal编程技术网

如何打包2个字符的数组+;2个带python的空字符';s结构?

如何打包2个字符的数组+;2个带python的空字符';s结构?,python,struct,binary,Python,Struct,Binary,你喜欢这个工作吗 var = struct.pack('2sb', code, 0) 其中代码是一个2字符的字符串 我想打包2个字符+2个空字符 即字母“ME”后跟两个空字符此代码生成«“ME”后跟两个空字符»: 结果: 'ME\x00\x00' 更简单地说,这也是: var = 'ME\x00\x00' print repr(var) 你说的数组是什么意思?您要打包的对象到底是什么? var = 'ME\x00\x00' print repr(var)

你喜欢这个工作吗

var = struct.pack('2sb', code, 0)
其中代码是一个2字符的字符串

我想打包2个字符+2个空字符

即字母“ME”后跟两个空字符

此代码生成«“ME”后跟两个空字符»:

结果:

'ME\x00\x00'
更简单地说,这也是:

var = 'ME\x00\x00'
print repr(var)

你说的数组是什么意思?您要打包的对象到底是什么?
var = 'ME\x00\x00'
print repr(var)