摘要:
<p> <input type="file" name="文件"></p><!--</select>-->省<select name="province" id=""> <option value="hebei">河北</option> <optgroup label="">河北省 <option> 阅读全文
摘要:
import time,randomimport queue,threadingq = queue.Queue()def Producer(name): count = 0 while count <10: print("making........") time.sleep(5) q.put(co 阅读全文
摘要:
服务端import socketphone=socket.socket(socket.AF_INET,socket.SOCK_STREAM)#(基于网络通信,TCP协议)phone.bind(('127.0.0.1',8000))#绑定电话卡phone.listen(5)# 最多几个等电话,开机pr 阅读全文
摘要:
#1 异常类只能用来处理指定的异常情况,如果非指定异常则无法处理。 s1 = 'hello' try: int(s1) except IndexError as e: # 未捕获到异常,程序直接报错 print e #2 多分支 s1 = 'hello' try: int(s1) except In 阅读全文
摘要:
异常就是程序运行时发生错误的信号(在程序出现错误时,则会产生一个异常,若程序没有处理它,则会抛出该异常,程序的运行也随之终止),在python中,错误触发的异常如下 阅读全文
摘要:
v 阅读全文
摘要:
class Typed: def __init__(self,key,expected_type): self.key=key self.expected_type=expected_type def __get__(self, instance, owner): print('get方法') # 阅读全文
摘要:
with obj as f: '代码块' 1.with obj 》触发obj.__enter__(),拿到返回值 2.as f >f=返回值、 3.with obj as f 等同于 f=obj.__enter__() 4.执行代码块一:没有异常的情况下,整个代码块运行完毕后去触发__exit__, 阅读全文
摘要:
setattr(obj,'属性','属性的值') #obj.属性=属性的值delattr(obj,'属性') #del obj.属性 #__getattr__,__setattr__,__delattr__obj点的方式去操作属性时触发的方法 __getattr__:obj.属性 不存在时触发__s 阅读全文
摘要:
class Fib: def __init__(self): self._a=1 self._b=1 def __iter__(self): return self def __next__(self): if self._a > 100: raise StopIteration('终止了') se 阅读全文