from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
import time
class MyHandler(FileSystemEventHandler):
def on_modified(self, event):
print('Файл {} изменился'.format(event.src_path))
observer = Observer()
observer.schedule(MyHandler(), path="example.txt", recursive=False)
observer.start()
while True:
time.sleep(1)