作者在 2010-04-21 03:55:08 发布以下内容
先运行下面一段代码:
class A:
def __init__(self,url):
self.url = url
def out(self):
return self.url
a = A('news.163.com')
print a.out()
b = a.__class__('www.bccn.net')
print b.out()
print A
print a.__class__
def __init__(self,url):
self.url = url
def out(self):
return self.url
a = A('news.163.com')
print a.out()
b = a.__class__('www.bccn.net')
print b.out()
print A
print a.__class__
可以看出a.__class__就等效于a的类A