我正在使用信号处理程序捕获 ctrl-c 并想知道是否有比 go os.system("\b") 或类似方法更好的方法来隐藏打印到终端的 ^C 。我只真正关心 Unix。
def read(self, time_s):
setup = ['Sensor', 'sensors', '\x00']
# Closure for signal handler to allow access to self
def sigintHandler(*args):
self.close()
sys.stdout.write('\b\b\r') # Current solution
sys.stdout.flush()
sys.exit(0)
signal.signal(signal.SIGINT,sigintHandler)
Run Code Online (Sandbox Code Playgroud)
我目前的解决方案是上面
归档时间: |
|
查看次数: |
869 次 |
最近记录: |