随笔分类 -  python

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 48 下一页
摘要:code macname@MacdeMacBook-Pro Desktop % macname@MacdeMacBook-Pro Desktop % cat test.py import logging logging.basicConfig(level=logging.INFO, filename 阅读全文
posted @ 2020-12-03 14:00 anobscureretreat 阅读(124) 评论(0) 推荐(0) 编辑
摘要:code from queue import Queue from threading import Thread # 用来表示终止的特殊对象 _sentinel = object() # A thread that produces data def producer(out_q): for i 阅读全文
posted @ 2020-11-29 21:05 anobscureretreat 阅读(164) 评论(0) 推荐(0) 编辑
摘要:code from queue import Queue from threading import Thread class Producer(Thread): def __init__(self, q): super().__init__() self.count = 5 self.q = q 阅读全文
posted @ 2020-11-29 21:00 anobscureretreat 阅读(165) 评论(0) 推荐(0) 编辑
摘要:code import multiprocessing from multiprocessing import Pool,Queue import time import threading import gevent from gevent import monkey monkey.patch_a 阅读全文
posted @ 2020-11-29 20:38 anobscureretreat 阅读(105) 评论(0) 推荐(0) 编辑
摘要:python中Queue是消息队列,提供线程间通信机制,python3中重名为为queue Queue模块中的类:Queue(maxsize=0):创建一个FIFO队列,若给定最大值,队列没有空间时阻塞,否则是无限队列LifoQueue(maxsize=0):创建一个栈,maxsize含义同上Pri 阅读全文
posted @ 2020-11-29 20:29 anobscureretreat 阅读(406) 评论(0) 推荐(0) 编辑
摘要:code import threading import time from queue import Queue def test(data,que,index): for i in data: if(i==8900): que.put(i) print(index," ",i) pass if 阅读全文
posted @ 2020-11-29 20:13 anobscureretreat 阅读(236) 评论(0) 推荐(0) 编辑
摘要:code import multiprocessing from multiprocessing import Pool import time import threading g_num = 0 def test1(): for i in range(10): time.sleep(1) pri 阅读全文
posted @ 2020-11-29 20:00 anobscureretreat 阅读(234) 评论(0) 推荐(0) 编辑
摘要:code import time import threading class MyCounter(threading.Thread): """自定义线程类型,继承threading.Thread类""" # 类属性 num = 1 def run(self): """重写run方法,在线程star 阅读全文
posted @ 2020-11-29 19:57 anobscureretreat 阅读(140) 评论(0) 推荐(0) 编辑
摘要:code import gevent,time from gevent import monkey monkey.patch_all() #gevent三行放在其他所有import语句之前可以避免出现警告或者报错信息,导致程序不能正常运行 def test1(): for i in range(10 阅读全文
posted @ 2020-11-29 19:54 anobscureretreat 阅读(105) 评论(0) 推荐(0) 编辑
摘要:code """ 守护线程:一个子线程,会随着主线程的退出直接退出 不论子线程中是否执行完成 不离不弃,死生相随 """ import threading import time def test(): while True: print(f"{threading.current_thread(). 阅读全文
posted @ 2020-11-29 11:01 anobscureretreat 阅读(358) 评论(0) 推荐(0) 编辑
摘要:code macname@MacdeMBP Desktop % macname@MacdeMBP Desktop % cat test.py import time from multiprocessing import Process def func(name, sec): print(name 阅读全文
posted @ 2020-11-28 23:19 anobscureretreat 阅读(275) 评论(0) 推荐(0) 编辑
摘要:code macname@MacdeMBP Desktop % macname@MacdeMBP Desktop % cat test.py import time from multiprocessing import Process def func(name): print(f"我是{name 阅读全文
posted @ 2020-11-28 23:18 anobscureretreat 阅读(158) 评论(0) 推荐(0) 编辑
摘要:code macname@localhost Desktop % cat exce.py import sys def tmp_func(): print(sys._getframe().f_code.co_name) tmp_func() macname@localhost Desktop % p 阅读全文
posted @ 2020-11-27 19:15 anobscureretreat 阅读(633) 评论(0) 推荐(0) 编辑
摘要:code import time import datetime t1=time.time() time.sleep(0.02) t2=time.time() print("相差",(datetime.datetime.fromtimestamp(t2)-datetime.datetime.from 阅读全文
posted @ 2020-11-27 19:13 anobscureretreat 阅读(2806) 评论(2) 推荐(0) 编辑
摘要:code import json new_dict={"func_name":"https://www.cnblogs.com/bigberg/p/6430095.html"} with open("record.json","w") as f: json.dump(new_dict,f) with 阅读全文
posted @ 2020-11-27 19:12 anobscureretreat 阅读(182) 评论(0) 推荐(0) 编辑
摘要:code import hashlib from cv2 import VideoCapture from moviepy.editor import * import os dir_paths = os.path.join(os.path.dirname(os.path.abspath(__fil 阅读全文
posted @ 2020-11-18 23:15 anobscureretreat 阅读(607) 评论(0) 推荐(0) 编辑
摘要:code1 import os import shutil pwd=os.getcwd() fpath=os.path.join(pwd,"dian") target=os.path.join(pwd,"电子书") c=0 for i in os.listdir(fpath): d=os.path. 阅读全文
posted @ 2020-11-11 20:15 anobscureretreat 阅读(1515) 评论(0) 推荐(0) 编辑
摘要:code # !/usr/bin/python # -*- coding:utf-8 -*- # time: 2019/07/21--20:12 __author__ = 'Henry' ''' 项目: B站动漫番剧(bangumi)下载 版本2: 无加密API版,但是需要加入登录后cookie中的 阅读全文
posted @ 2020-11-10 16:41 anobscureretreat 阅读(2224) 评论(0) 推荐(0) 编辑
摘要:code with open("test") as f: for line in f.readlines(): if(line): print(line,"<br>") 阅读全文
posted @ 2020-11-03 16:26 anobscureretreat 阅读(91) 评论(0) 推荐(0) 编辑
摘要:code import os import shutil pwd=os.getcwd() for i in os.listdir(pwd): d=os.path.join(pwd,i) if(os.path.isdir(d)): for j in os.listdir(d): f=os.path.j 阅读全文
posted @ 2020-11-03 16:24 anobscureretreat 阅读(797) 评论(0) 推荐(0) 编辑

上一页 1 ··· 3 4 5 6 7 8 9 10 11 ··· 48 下一页