【发布时间】:2019-12-04 10:01:16
【问题描述】:
我自己编写了一个简单的代码,但它在任何 python IDE 中都不起作用,例如 pycharm 和 Wing IDE。但它在终端中正常工作。
在IDE中,不断出现错误“NameError: name 'pack' is not defined”
我正在使用 kali linux。
我已经尝试过检查 struct.py 文件
from struct import *
packed_data = pack("iif", 6, 19, 4.73)
print(packed_data)
construct.py 代码
__all__ = [
# Functions
'calcsize', 'pack', 'pack_into', 'unpack', 'unpack_from',
'iter_unpack',
# Classes
'Struct',
# Exceptions
'error'
]
from _struct import *
from _struct import _clearcache
from _struct import __doc__
【问题讨论】:
-
我编辑了,抱歉我不习惯stackoverflow
-
@Colin 你能验证一下是否可以在 python 内置 ide 上导入结构,因为你的代码可以在我的系统上运行
-
@Colin 也检查 python 版本
-
@Doodle 当我输入导入结构时也会弹出。我在我的代码和模块中没有看到任何问题。我的是 3.7.3
-
我想我现在为什么,因为文件夹中有一个名为
struct的模块