2
class UserDict:
def __init__(self, dict=None):
self.data = {}
if dict is not None: self.update(dict)
ファイル "abc.py"を作成し、上に置きました。なぜこのPythonは動作しませんか? Simple Oop
>>> import abc
>>> d = abc.UserDict()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'module' object has no attribute 'UserDict'
はい、おそらく、あなたが思っているabcをインポートしていないでしょう。 'print abc .__ file__'をチェックしてください。 – TryPyPy
Pythonについての厄介なことは、 –
'help(abc)'もこのような問題を診断する良いツールであるということです。 – Johnsyweb