【发布时间】:2018-03-23 12:14:05
【问题描述】:
在 python3 中,我有一些字节。我想将它们导出到 C 源代码。 在 python 之外,我使用“xxd -i binary_file”命令。
例子:
x = b'abc123'
print(bytes_to_c_arr(x))
# should output:
unsigned char x[] = { 0x61, 0x62, 0x63, 0x31, 0x32, 0x33 };
是否有现成的方法或方便的单线?我可以不用类型声明,只需要内容的字节就足够了。
【问题讨论】:
标签: python arrays python-3.x byte