
现在的实现思路是:
import os, sys, time while True: output = str(time.time()) os.system('clear') sys.stdout.write(output) sys.stdout.flush() time.sleep(1) 但发现每次刷新的时候都会闪一下,而 watch 是不会的,求教有办法改进吗
1 ysc3839 2022-12-20 10:56:06 +08:00 可以看看 watch 的源代码,比如 busybox 的 watch https://git.busybox.net/busybox/tree/procps/watch.c 就只是 printf(ESC"[H" ESC"[J"); 而 procps-ng 的 watch 则复杂很多 https://gitlab.com/procps-ng/procps/-/blob/master/src/watch.c |