小编Del*_*ela的帖子

struct pack返回太长

我正在尝试使用该struct.pack功能

import struct
values = (0, 44)
s = struct.Struct('HI')
b = s.pack(*values)
print(b)
print(str(len(b)))
Run Code Online (Sandbox Code Playgroud)

它给了我这个输出:

b'\x00\x00\x00\x00,\x00\x00\x00'
8
Run Code Online (Sandbox Code Playgroud)

python文档说:

Format - C Type         - Python type - Standard size - Notes

H      - unsigned short - integer     - 2             - (3)

I      - unsigned int   - integer     - 4             - (3)
Run Code Online (Sandbox Code Playgroud)

所以len()应该是2 + 4 = 6,我需要大小= 6的字节

有任何想法吗?

我在Windows 10上使用Python 3.6

python struct pack

7
推荐指数
1
解决办法
473
查看次数

生成 .NET EAN-13 字符串

有人可以推荐一个(免费用于商业用途)库来生成 EAN-13 条形码吗?

我不需要图像,只需要字符串。

我想传递产品代码、制造商代码和国家/地区(不是数字系统)作为参数。

它可以将国家/地区转换为数字系统,将其连接在一起并计算校验和。

.net barcode ean-13

2
推荐指数
1
解决办法
3557
查看次数

标签 统计

.net ×1

barcode ×1

ean-13 ×1

pack ×1

python ×1

struct ×1