python判断文件是否存在
os.path.exists(file_path):
python多线程
p1 = threading.Thread(target=down) t1 = threading.Thread(target=crawl) print("启动") p1.start() t1.start() print("join") p1.join() t1.join()
python多线程与redis控制多线程的数量
while True: try: if threading.active_count() > 10: time.sleep(10) else: data1 = r1.get("cartoon_data") if data1 is None: time.sleep(10) continue else: data = json.loads(data1) file_path= data.get("file_path") ts_urls= data.get("ts_urls") if os.path.exists(file_path): continue t1 = threading.Thread(target=download_ts, args=(ts_urls, file_path)) t1.start() t1.join() print(t1.name) except Exception as e: print("eeee",e.args) pass
python 两个列表中有重复元素,去重且合并
t11 = url2.split("/") t22 = re_s.split("/") t33 = t11 + t22 for tmp in t11: if (tmp in t22): t22.remove(tmp)
python redis工具类
class Redis: def __init__(self,db): self.r = redis.StrictRedis(host="x", db=db) def lpush(self,key,values): self.r.lpush(key,values) def get(self,key): return self.r.rpop(key) def __del__(self): self.r.close()
python m3u8
#EXTM3U #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=800000,RESOLUTION=1080x608 2000k/hls/mixed.m3u8 这个文件没有ts文件 需要将2000k/hls/mixed.m3u8 url拼接重新获取一个m3u8文件,之后会获取到带有ts字段的内容,然后url拼接,requests请求,获取响应的内容,将内容拼接在一起,写入到文件,最后得到完整的视频文件
标签:python,self,ts,t1,file,path,相关 From: https://www.cnblogs.com/lzjloveit/p/17352456.html