我正在尝试使用 Python Watchdog 来监视目录的更改。但是,当我尝试运行快速入门示例时:
import time
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler
if __name__ == "__main__":
event_handler = LoggingEventHandler()
observer = Observer()
observer.schedule(event_handler, path='.', recursive=True)
observer.start()
try:
while True:
time.sleep(1)
except KeyboardInterrupt:
observer.stop()
observer.join()
通过将文件test.py放入其中,我运行它的终端窗口中不会显示任何内容。是什么导致这种情况发生,我该如何解决?