摘要: 参考链接:http://www.cnblogs.com/alex3714/articles/5248247.html 阅读全文
posted @ 2018-05-07 10:32 Py小白 阅读(173) 评论(0) 推荐(0) 编辑
摘要: 队列: 先进先出 后进先出 VIP(优先级) import queue # q = queue.LifoQueue()#后进先出 # # q.put(1) # q.put(2) # q.put(3) # print(q.get()) # print(q.get()) # print(q.get()) 阅读全文
posted @ 2018-04-08 16:29 Py小白 阅读(248) 评论(0) 推荐(0) 编辑
摘要: import time,threading event = threading.Event() def lighter(): count = 0 event.set() while True: if count > 5 and count < 10:#改成红灯 event.clear()#把标志位清 阅读全文
posted @ 2018-04-08 16:27 Py小白 阅读(1417) 评论(0) 推荐(0) 编辑
摘要: 1 import threading,time 2 3 def run(n): 4 semaphore.acquire() 5 time.sleep(1) 6 print("run the thread: %s\n" %n) 7 semaphore.release() 8 9 if __name__ 阅读全文
posted @ 2018-03-30 15:47 Py小白 阅读(136) 评论(0) 推荐(0) 编辑
摘要: 守护线程:只起到守护主线程的作用,主线程退出守护线程也跟着退出。 1 import threading,time 2 3 def run(n): 4 print("task",n) 5 time.sleep(2) 6 print("task done",n) 7 8 start_time = tim 阅读全文
posted @ 2018-03-27 06:43 Py小白 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 参考链接:http://www.cnblogs.com/alex3714/articles/5230609.html 1 import threading,time 2 3 def run(n): 4 print("task",n) 5 time.sleep(2) 6 print("task don 阅读全文
posted @ 2018-03-15 18:20 Py小白 阅读(147) 评论(0) 推荐(0) 编辑
摘要: 本节内容 1. Socket介绍 概念 A network socket is an endpoint of a connection across a computer network. Today, most communication between computers is based on 阅读全文
posted @ 2018-03-06 15:10 Py小白 阅读(1336) 评论(0) 推荐(0) 编辑
摘要: 服务端 ##sock_server_ssh import socket,os server = socket.socket() server.bind(('localhost',9999)) server.listen() while True: print("接收新指令") conn,addr = 阅读全文
posted @ 2018-02-28 16:25 Py小白 阅读(753) 评论(0) 推荐(0) 编辑
摘要: 静态方法 与类无关,不能访问类里的任何属性和方法类方法 只能访问类变量属性@property 把一个方法变成一个静态属性 flight.status @status.setter flight.status = 3 @status.delter反射 getattr(obj,str) setattr( 阅读全文
posted @ 2018-02-27 15:44 Py小白 阅读(206) 评论(0) 推荐(0) 编辑
摘要: 参考链接:http://www.cnblogs.com/alex3714/articles/5830365.html 动态导入模块 1 *动态导入模块代码 2 3 4 #from lib import "aa" 5 #import lib 6 lib = __import__('lib.aa') 7 阅读全文
posted @ 2018-02-27 12:09 Py小白 阅读(185) 评论(0) 推荐(0) 编辑