我知道这是个简单的问题,但我做不到。我得做两件事。其中一个是管理程序,例如停止、暂停、恢复。另一件事只会显示日志。所以我需要两台游戏机。
if __name__ == '__main__':
try:
while True:
initialmyProgram()
print('Please press \'1\' key to stop program..\n')
print('Please press \'5\' key to resume program..\n')
print('Please press \'0\' key to exit program..\n')
isStart = raw_input('Please press a key that must be in above list..')
if isStart == 1:
parse.__is__process__ = False
elif isStart == 5:
parse.__is__process__ = True
elif isStart == 0 :
exit_program()
else:
continue
except Exception as ex:
logging.info('log..') #this log will write other console..发布于 2013-07-01 13:34:14
您实际上并不需要两个python控制台来完成这一任务。
如果您使用的是linux或mac,请打开python控制台和第二个终端。
然后在第二个终端中键入以下命令:
tail -f path_to/filename_of_logfile这将自动刷新日志文件。
如果您绝对不能使用文件,另一种解决方案是使用套接字来使python程序进行通信。这里有一个让你开始的链接:
https://stackoverflow.com/questions/17405682
复制相似问题