AttributeError:'module'对象没有属性'ClassType'

use*_*359 -1 python attributeerror

好的,所以我一直在尝试输入命令:python但它最终会吐出来:

Traceback (most recent call last):
  File "C:\Python27\lib\site.py", line 62, in <module>
    import os
  File "C:\Python27\lib\os.py", line 398, in <module>
    import UserDict
  File "C:\Python27\lib\UserDict.py", line 83, in <module>
    import _abcoll
  File "C:\Python27\lib\_abcoll.py", line 70, in <module>
    Iterable.register(str)
  File "C:\Python27\lib\abc.py", line 107, in register
    if not isinstance(subclass, (type, types.ClassType)):
AttributeError: 'module' object has no attribute 'ClassType'
Run Code Online (Sandbox Code Playgroud)

我将types.py重命名为nottypes.py但它仍然给我完全相同的消息.

Ign*_*ams 15

你在sys.path"types.py"中调用了其他东西.重命名它.

  • 也删除.pyc文件. (2认同)

mud*_*ish 6

在 python 3 中,ClassType 从types. 你可以isinstance(var_name, type)改用。