所以我在如何從python調用外部命令上發現了這一點,但是我如何使用此方法,而是將命令的輸出輸出輸出到外部文件中。所以從本質上講,我需要將命令的輸出存儲為文本文件。這可能嗎?我找不到太多關于如何做到這一點的信息,我發現的那些還不清楚這是我當前的代碼,但它只是在屏幕上顯示輸出,我不知道如何將其存儲為文件 #!/usr/bin/python## get subprocess module import subprocess## call date command ##p = subprocess.Popen("date", stdout=subprocess.PIPE, shell=True)## Talk with date command i.e. read data from stdout and stderr. Store this info in tuple #### Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. #### Wait for process to terminate. The optional input argument should be a string to be sent to the child process, #### or None, if no data should be sent to the child.(output, err) = p.communicate()## Wait for date to terminate. Get return returncode ##p_status = p.wait()print "Command output : ", outputprint "Command exit status/return code : ", p_statu
添加回答
舉報
0/150
提交
取消