关于 python 的类

 查看类的属性
用 dir(Classname) 仅返回对象的属性的一个名字列表

classname.__dict__ 返回一个字典,他的key是属性名, 键值是相应的属性对象的数据值


关于  __name__

#test15.py
class Stuent():
def __init__(self,name,age):
self.name = name
self.age = age
def printinfo(self):
print "my name is %s ,and age is %d" %(self.name,self.age)

print Stuent.__module__ ##  __main__


#
from test15 import Stuent

print Stuent.__module__ ##test15

原文地址:https://www.cnblogs.com/jkklearn/p/13742604.html