python 捕獲 shell/bash 腳本的輸出結(jié)果實(shí)例
#!/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 : ", output
print "Command exit status/return code : ", p_status
## from: http://www.cyberciti.biz/faq/python-run-external-command-and-get-output/
以上就是小編為大家?guī)淼膒ython 捕獲 shell/bash 腳本的輸出結(jié)果實(shí)例全部?jī)?nèi)容了,希望大家多多支持腳本之家~
相關(guān)文章
python高效過濾出文件夾下指定文件名結(jié)尾的文件實(shí)例
今天小編就為大家分享一篇python高效過濾出文件夾下指定文件名結(jié)尾的文件實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-10-10
Python使用collections模塊實(shí)現(xiàn)擴(kuò)展數(shù)據(jù)類
Python?標(biāo)準(zhǔn)庫提供了一個(gè)?collections?模塊,里面提供了很多的數(shù)據(jù)類,在工作中使用這些類能夠簡(jiǎn)化我們的開發(fā),本文就來看看collections是如何實(shí)現(xiàn)擴(kuò)展數(shù)據(jù)類的吧2023-06-06
pygame實(shí)現(xiàn)簡(jiǎn)單五子棋游戲
這篇文章主要為大家詳細(xì)介紹了pygame實(shí)現(xiàn)簡(jiǎn)單五子棋游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下<BR>2022-01-01
Python如何對(duì)音視頻文件進(jìn)行解析詳解
在腳本或應(yīng)用程序中,我們需要執(zhí)行音頻處理任務(wù),下面這篇文章主要給大家介紹了關(guān)于Python如何對(duì)音視頻文件進(jìn)行解析的相關(guān)資料,文中通過實(shí)例代碼介紹的非常詳細(xì),需要的朋友可以參考下2022-11-11
python實(shí)現(xiàn)連續(xù)圖文識(shí)別
這篇文章主要為大家詳細(xì)介紹了python實(shí)現(xiàn)連續(xù)圖文識(shí)別功能,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2018-12-12
python爬取免費(fèi)代理并驗(yàn)證代理是否可用
這篇文章主要介紹了python爬取免費(fèi)代理并驗(yàn)證是否可用,通過本文給大家介紹了在什么情況下會(huì)用到代理并分享腳本的完整代碼,需要的朋友可以參考下2022-01-01
python?AutoViz庫一行代碼實(shí)現(xiàn)可視化數(shù)據(jù)集
這篇文章主要介紹了python?AutoViz庫一行代碼實(shí)現(xiàn)可視化數(shù)據(jù)集實(shí)例探索,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2024-01-01

