小编use*_*678的帖子

使用python watchdog检查特定文件已被修改

我想知道如何检查文件夹下特定文件的更改。我发现看门狗模块可以检查文件夹中文件的更改,但我只需要 1 个文件(具有固定名称)。

请对此提供帮助,谢谢。

class MyHandler(FileModifiedEvent):
    def on_modified(self, event):

if __name__ == "__main__":
        integrity_file_path = DATASTORE_DIRECTORY_PATH + '/schedule.xml'
        event_handler = MyHandler()
        observer = Observer()
        observer.schedule(MyHandler(), path=integrity_file_path,recursive=True)
        observer.start()

        try:
            while True:
                time.sleep(5)
        except KeyboardInterrupt:
            observer.stop()
        observer.join()
Run Code Online (Sandbox Code Playgroud)

python file watchdog

5
推荐指数
2
解决办法
7589
查看次数

标签 统计

file ×1

python ×1

watchdog ×1