上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页
摘要: import socketclient = socket.socket()#client.connect(('192.168.16.200',9999))client.connect(('localhost',9999))while True: cmd = input(">>:").strip() 阅读全文
posted @ 2018-11-17 03:07 rongye 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 静态方法 与类无关,不能访问类里的任何属性和方法类方法 只能访问类变量属性@property 把一个方法变成一个静态属性, flight.status @status.setter flight.status = 3 @status.delter反射 getattr(obj,str) setattr 阅读全文
posted @ 2018-11-17 02:34 rongye 阅读(147) 评论(0) 推荐(0) 编辑
摘要: import importlib __import__('import_lib.metaclass') #这是解释器自己内部用的,到lib层#importlib.import_module('import_lib.metaclass') #与上面这句效果一样,官方建议用这个,到metaclass子层 阅读全文
posted @ 2018-11-17 01:52 rongye 阅读(81) 评论(0) 推荐(0) 编辑
摘要: #客户端import socketclient = socket.socket() #声明socket类型,同时生成socket连接对象client.connect(('localhost',6969))while True: msg = input(">>:").strip() if len(ms 阅读全文
posted @ 2018-11-16 23:13 rongye 阅读(160) 评论(0) 推荐(0) 编辑
摘要: class AlexError(Exception): def __init__(self, msg): self.message = msg # def __str__(self): # return 'sdfsf'try: raise AlexError('数据库连不上')except Alex 阅读全文
posted @ 2018-11-16 10:40 rongye 阅读(78) 评论(0) 推荐(0) 编辑
摘要: http://www.cnblogs.com/wupeiqi/articles/5017742.html python中的异常种类非常多,每个异常专门用于处理某一项异常!!! try: # 主代码块 passexcept KeyError,e: # 异常时,执行该块 passelse: # 主代码块 阅读全文
posted @ 2018-11-16 09:58 rongye 阅读(183) 评论(0) 推荐(0) 编辑
摘要: def bulk(self): print("%s is yelling...." %self.name)class Dog(object): def __init__(self,name): self.name = name def eat(self,food): print("%s is eat 阅读全文
posted @ 2018-11-16 09:18 rongye 阅读(136) 评论(0) 推荐(0) 编辑
摘要: class MyType(type): def __init__(self, what, bases=None, dict=None): print("--MyType init ") super(MyType, self).__init__(what, bases, dict) def __cal 阅读全文
posted @ 2018-11-15 21:48 rongye 阅读(209) 评论(0) 推荐(0) 编辑
摘要: # class Foo(object):# def __init__(self, name):# self.name = name### f = Foo("alex")# print(type(f))# print(type(Foo))def func(self): print('hello %s' 阅读全文
posted @ 2018-11-15 20:43 rongye 阅读(184) 评论(0) 推荐(0) 编辑
摘要: __setitem__ name alex__delitem__ sdfdsf 阅读全文
posted @ 2018-11-15 20:29 rongye 阅读(124) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 15 下一页