我用 python 语言编写了一个使用复制模块的代码。当我在 pycharm 控制台中运行这段代码时,它没有错误,但在 pycharm GUI 环境中它给了我这个错误:
Traceback (most recent call last):
File "C:/....../python/deepshallowcopy.py", line 2, in <module>
from copy mport deepcopy
File "C:\Python34\lib\copy.py", line 114, in <module>
types.BuiltinFunctionType, type(Ellipsis),
AttributeError: 'module' object has no attribute 'BuiltinFunctionType'
我的代码是:
from copy import deepcopy
col3=["rrrr","bbbb"]
col4=deepcopy(col3)
print(col3,col4)
col3[0]="jfjdhf"
print(col3,col4)
请您参考如下方法:
仔细查看您的回溯,
Traceback (most recent call last):
File "C:/....../python/deepshallowcopy.py", line 2, in <module>
from copy import deepcopy
File "C:\Python34\lib\copy.py", line 114, in <module>
types.BuiltinFunctionType, type(Ellipsis),
AttributeError: 'module' object has no attribute 'BuiltinFunctionType'
您必须在运行 deepshallowcopy.py 文件的同一文件夹中有一个名为 types.py 的 Python 文件。
通过在与名为 types.py 的文件相同的文件夹中运行您的脚本,我能够重现此错误。
