简单小练习_阅读稍后提醒
Posted erick-l
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简单小练习_阅读稍后提醒相关的知识,希望对你有一定的参考价值。
#ReadManger(c) -> (tool & context) from time import ctime import os import threading import webbrowser class ReadManager(object): def __init__(self, config): self.read_time= config[‘time‘] self.folder_path = config[‘folder_path‘] self.urls = self.urls_parse(self.folder_path) def urls_parse(self,path): urls = [] for f in os.listdir(path): if not f.startswith(‘.‘): full_path = path + f with open(full_path,‘r‘) as raw_url: url = raw_url.read().split(‘URL=‘)[-1].strip(‘ ‘) urls.append(url) return urls def time_to_read(self): return self.read_time == ctime().split()[-2] def sent_to_browser(self): for url in self.urls: webbrowser.open_new_tab(url) def run(self): def _run(): while True: if self.time_to_read: self.sent_to_browser() t = threading.Thread(target=_run) t.daemon =True t.start() managers = [ReadManager(c) for c in CONFIGS] # for m in managers: # m.run()
以上是关于简单小练习_阅读稍后提醒的主要内容,如果未能解决你的问题,请参考以下文章