AttributeError: partially initialized module 'struct' has no attribute 'pack' (most likely due to a
报错:AttributeError: partially initialized module ‘struct’ has no attribute ‘pack’ (most likely due to a circular import)
struct.py
#!/usr/bin/python3
import struct
# native byteorder
buffer = struct.pack("ihb", 1, 2, 3)
print(repr(buffer))
print(struct.unpack("ihb", buffer))
# data from a sequence, network byteorder
data = [1, 2, 3]
buffer = struct.pack("!ihb", *data)
print(repr(buffer))
print(struct.unpack("!ihb", buffer))
原因:文件名和import的包名一致,把文件名改了就好了
还没有评论,来说两句吧...