标签:
#!/usr/bin/env python
#-*- coding:utf-8 -*-
# powered by xiaobing
class A(object):
pass
class B(A):
pass
obj = B()
print isinstance(obj,B) #判断obj是不是B的对象
print isinstance(obj,A) #判断obj是不是 A的对象
print issubclass(B,A) #判断B是不是A的子类
print issubclass(B,int) #判断B是不是int子类
try
:
# 主代码块
pass
except
KeyError,e:
# 异常时,执行该块
pass
else
:
# 主代码块执行完,执行该块
pass
finally
:
# 无论异常与否,最终执行该块
pass
class Foo(object):
static_name = ‘test‘
def __init__(self):
self.name = ‘xiaobing‘
@staticmethod
def staic_show():
pass
@classmethod
def class_show(cls):
pass
obj = Foo()
print Foo.__dict__.keys()
print hasattr(Foo,‘static_name‘)
print obj.__dict__
print hasattr(obj,‘static_name‘)
setattr(obj,‘age‘,‘12‘)
print obj.__dict__
import home
print ‘oldboy....‘
url = raw_input(‘please input your want view page num(home/page1): ‘)
if url == ‘home/page1‘:
home.page1()
elif url == ‘home/page2‘:
home.page2()
elif url == ‘home/page3‘:
home.page3()
elif url == ‘home/page4‘:
home.page4()
elif url == ‘home/page5‘:
home.page5()
标签:
原文地址:http://www.cnblogs.com/xiaobing1024/p/5058287.html