Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在这里做错了吗?
>>> import numpy as np >>> dt = np.dtype({"names": ["First"], "formats": [np.uint32], "offsets": [3], "itemsize": 8}) >>> dt.itemsize 7
对我来说它看起来像一个错误。但是,如果您最后只需要 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 )