Python 2.7 python守护进程stdout、stderr重定向;如何?
我有一个较大py文件的小片段,其中我试图将stdout、stderr重定向到桌面上的两个独立文件 仅供参考:我可以在没有守护进程的情况下成功运行相同的行。(#thread.daemon=True) 如果我需要提供更多细节,请告诉我 [注:我实际上正在尝试在同一个函数中运行seleniumRC脚本]Python 2.7 python守护进程stdout、stderr重定向;如何?,python-2.7,selenium,stdout,daemon,stderr,Python 2.7,Selenium,Stdout,Daemon,Stderr,我有一个较大py文件的小片段,其中我试图将stdout、stderr重定向到桌面上的两个独立文件 仅供参考:我可以在没有守护进程的情况下成功运行相同的行。(#thread.daemon=True) 如果我需要提供更多细节,请告诉我 [注:我实际上正在尝试在同一个函数中运行seleniumRC脚本] def onCallDelete(): tenantId="Codebreakers" import time,os, sys time.sleep(2) os.chd
def onCallDelete():
tenantId="Codebreakers"
import time,os, sys
time.sleep(2)
os.chdir('/Users/pie/Desktop')
sys.stdout = open('stdoutf.txt', 'w') #assigning file descriptor
sys.stderr = open('stderrf.txt', 'w') #assigning file descriptor
sys.stdout.write("hellooooe, this logs to a file")
sys.stdout.close()
sys.stderr.close()
thread = threading.Thread(target=onCallDelete)
thread.daemon = True
thread.start()