day7

静态方法:实际上就是单纯的方法,跟类已经没什么关系,名义上归类管。@staticmethod

类方法:只能访问类变量,不能访问实例变量(self.name)@classmethod

属性方法:把一个方法编程静态属性,不能传参数。@property

 

类反射:

hasattr(obj,name_str),判断一个对象obj里是否有相应的name_str字符串对应的方法

getattr(obj,name_str),获取对象obj里的name_str字符串对应方法的内存地址

setattr(obj,'y',z)is equila to obj.y = z

delattr(obj,name_str)删除对象的属性或方法

 

异常:

  try:
    code

  except(error1,error2) as e:

    print(e)

  except Exception as e:#没有抓取到的错误

    print(e)

  else:#没有错误时执行

    print 

  finally:

    不管有没有错误都执行

 

Socket

 

posted @ 2018-08-05 18:58  老董1983  阅读(135)  评论(0编辑  收藏  举报