35
잠시 동안 나를 괴롭혔던 것이 있습니다. 내가 할 수없는 이유 :파이썬 객체에 속성 추가하기
>>> a = ""
>>> a.foo = 2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'str' object has no attribute 'foo'
... 나는 다음을 할 수 있습니까?
여기에 어떤 규칙이 적용됩니까? 좀 설명해 주시겠습니까?
btw,'class Bar() :'대신'class Bar (object) :'를 사용해야 새로운 스타일의 클래스를 얻을 수 있습니다. – ThiefMaster