我不太了解 python,但从文档中可以看出代码:
str = "AAAA"
str += pack("<I", 0)
会将 pack 函数的结果附加到 str,这将是小端格式的整数值 0。我的问题是这个的 C 等价物是什么。难道只是:
char str[20] = "AAAA";
strcat(str, "\x00");
?...
最佳答案
strcat()
在第一个 NUL 处停止,所以不会。
char str[20] = "AAAA";
int val = 0;
int nval = htole32(val);
memcpy(str + 4, (char*)&nval, 4);
关于python - Python 包 ("<I"的 C 等效项是什么,0),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10771070/