这是脚本
#!/usr/bin/python
class LEG(Structure):
_fields_ = [("distance_sm", c_float), ("distance_nm", c_float)]
Run Code Online (Sandbox Code Playgroud)
这是我运行时得到的.
Traceback (most recent call last):
File "./test.py", line 3, in <module>
class LEG(Structure):
NameError: name 'Structure' is not defined
Run Code Online (Sandbox Code Playgroud)
是的,蟒蛇新品,谢谢你的帮助
看起来你正在尝试使用模块中的Structure类型ctypes.您需要导入c_float该模块以及您在该模块中使用的任何其他内容:
from ctypes import Structure, c_float
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
142 次 |
| 最近记录: |