AttributeError:'module'对象在pycharm中没有属性'BuiltinFunctionType'

MaS*_*ehr 1 python pycharm

我用python语言编写了一个使用copy模块的代码.当我在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'
Run Code Online (Sandbox Code Playgroud)

我的代码是:

from copy import deepcopy
col3=["rrrr","bbbb"]
col4=deepcopy(col3)
print(col3,col4)
col3[0]="jfjdhf"
print(col3,col4)
Run Code Online (Sandbox Code Playgroud)

Luk*_*ard 6

仔细看看你的追溯,

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'
Run Code Online (Sandbox Code Playgroud)

您必须types.py在运行deepshallowcopy.py文件的同一文件夹中指定一个Python 文件.

我能够通过在与命名文件相同的文件夹中运行脚本来重现此错误types.py.