随笔分类 -  python

摘要:import json str=['abb',456,True,False] # json_str=json.dumps(str) # with open ('test.json','w') as f: # f.write(json_str) # with open ('test.json','w' 阅读全文
posted @ 2021-02-20 01:33 丑矬穷屌 阅读(30) 评论(0) 推荐(0)
摘要:import pymysql conn=pymysql.connect( host='127.0.0.1', port=3306, user='root', password='999', database='day14', charset='utf8', autocommit=1 #自动提交,不设 阅读全文
posted @ 2021-02-15 22:35 丑矬穷屌 阅读(74) 评论(0) 推荐(0)
摘要:from gevent import monkey;monkey.patch_all()import timefrom gevent import spawndef pp(): print('ppstar') time.sleep(2) print('ppover')def oo(): print( 阅读全文
posted @ 2021-02-02 18:27 丑矬穷屌 阅读(77) 评论(0) 推荐(0)
摘要:from threading import Thread,Eventimport timeevent=Event()def wait(): print('wait==') time.sleep(2) print('over!') event.set()def go(i): print(f'{i},Z 阅读全文
posted @ 2021-02-02 18:02 丑矬穷屌 阅读(224) 评论(0) 推荐(0)
摘要:from threading import Thread,Semaphore #类似锁的一个东西import timelock_num=Semaphore(2) #设置锁的数量def test(name): lock_num.acquire() print(f'{name}已加入') time.sl 阅读全文
posted @ 2021-02-02 17:52 丑矬穷屌 阅读(77) 评论(0) 推荐(0)
摘要:from concurrent.futures import ThreadPoolExecutor,ProcessPoolExecutorimport timedef func(i): print('star', i) time.sleep(2) return f'over,{i}'def cb(r 阅读全文
posted @ 2021-02-02 12:27 丑矬穷屌 阅读(84) 评论(0) 推荐(0)
摘要:import socketfrom threading import Threadserver = socket.socket(socket.AF_INET,socket.SOCK_STREAM)server.bind(('127.0.0.1',8080))server.listen(5)# def 阅读全文
posted @ 2021-02-01 00:22 丑矬穷屌 阅读(86) 评论(0) 推荐(0)
摘要:from multiprocessing import Process,JoinableQueueimport randomimport timedef fang(jq,ll): for i in range(3): ran=random.randint(1,3) name=random.choic 阅读全文
posted @ 2021-01-31 21:47 丑矬穷屌 阅读(139) 评论(0) 推荐(0)
摘要:from multiprocessing import Queue,Processdef fang(queue): queue.put('你愁啥')def qu(queue): print(queue.get())if __name__ == '__main__': q=Queue() p_fang 阅读全文
posted @ 2021-01-31 20:51 丑矬穷屌 阅读(96) 评论(0) 推荐(0)
摘要:from multiprocessing import Queueq = Queue(3)q.put('aaa')q.put('bbb')q.put('ccc')print(q.full()) #判断当前队列是否已满print(q.empty()) #判断队列是否为空a = q.get()b = q 阅读全文
posted @ 2021-01-31 20:38 丑矬穷屌 阅读(47) 评论(0) 推荐(0)
摘要:from multiprocessing import Process, Lockimport jsonimport timedef search(i): with open('data', 'r', encoding='utf8') as f: dic = json.load(f) num = d 阅读全文
posted @ 2021-01-31 20:11 丑矬穷屌 阅读(40) 评论(0) 推荐(0)
摘要:1、去管网(https://www.python.org/downloads/source/),找Gzipped source tarball的链接 2、下载。wget 链接地址 3、解压。tar -xvf .tgz文件 4、切换到解压后的目录中(cd Python-3.8.7),执行./confi 阅读全文
posted @ 2021-01-30 10:38 丑矬穷屌 阅读(69) 评论(0) 推荐(0)