Update print.py
Browse files
print.py
CHANGED
@@ -12,14 +12,12 @@ def read_and_print_file():
|
|
12 |
except Exception as e:
|
13 |
print(f"An unexpected error occurred: {e}")
|
14 |
|
15 |
-
#
|
16 |
-
interval = 10 #
|
17 |
-
|
18 |
print("Starting task. Press Ctrl+C to stop.")
|
19 |
try:
|
20 |
while True:
|
21 |
read_and_print_file()
|
22 |
-
print(f"Sleeping for {interval} seconds...")
|
23 |
time.sleep(interval)
|
24 |
except KeyboardInterrupt:
|
25 |
print("\nTask stopped.")
|
|
|
12 |
except Exception as e:
|
13 |
print(f"An unexpected error occurred: {e}")
|
14 |
|
15 |
+
# 定时任务,每隔10秒打印一次
|
16 |
+
interval = 10 # 设置间隔时间(秒)
|
|
|
17 |
print("Starting task. Press Ctrl+C to stop.")
|
18 |
try:
|
19 |
while True:
|
20 |
read_and_print_file()
|
|
|
21 |
time.sleep(interval)
|
22 |
except KeyboardInterrupt:
|
23 |
print("\nTask stopped.")
|