我在这里做错了吗?
>>> import numpy as np
>>> dt = np.dtype({"names": ["First"],
"formats": [np.uint32],
"offsets": [3],
"itemsize": 8})
>>> dt.itemsize
7
答案 0 :(得分:2)
对我来说这看起来像个错误。但是如果你最后只需要n个字节的填充,那么复合类型可能会有所帮助:
import numpy as np
dt = np.dtype({"names": ["First", "_"],
"formats": [np.uint32, (np.void,1)],
"offsets": [3,7],
})
arr = np.empty( (5,), dtype=dt )