pythonbook/Python高级编程/对象管理属性.py

8 lines
238 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

class Spring(object):
#season 为类的属性
season = "the spring of class"
print(Spring.__dict__)
print(Spring.__dict__['season'])
# 实例属性的__dict__是空的因为season是属于类属性
s= Spring()
print(s.__dict__)