Python struct.pack()';struct.error:struct格式的错误字符';当试图保存endianess时
我正在尝试打包一根绳子和一根绳子的长度Python struct.pack()';struct.error:struct格式的错误字符';当试图保存endianess时,python,struct,Python,Struct,我正在尝试打包一根绳子和一根绳子的长度 fmt = '<P' + str(len(string)) + 'p' 没有给我一个错误。我无法理解为什么会发生这种情况,我的理解是从struct模块docstring指定“: The remaining chars indicate types of args and must match exactly; ... Special case (only available in native format): P:an integer typ
fmt = '<P' + str(len(string)) + 'p'
没有给我一个错误。我无法理解为什么会发生这种情况,我的理解是从
struct
模块docstring指定“:
The remaining chars indicate types of args and must match exactly;
...
Special case (only available in native format):
P:an integer type that is wide enough to hold a pointer.
因此,在使用p
格式时,不能修改尾数;它仅以本机格式提供
另请参见此处的注释5:“在文档中忽略了这一点:(.我想我将使用long-long而不是指针,我只需要一个大的无符号整数来指定字符串的长度。
The remaining chars indicate types of args and must match exactly;
...
Special case (only available in native format):
P:an integer type that is wide enough to hold a pointer.