国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > Python > 正文

python 捕獲 shell/bash 腳本的輸出結(jié)果實例

2020-02-23 04:14:26
字體:
供稿:網(wǎng)友

#!/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é)果實例全部內(nèi)容了,希望大家多多支持武林站長站~

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 衡南县| 宾阳县| 苗栗市| 那曲县| 碌曲县| 宁城县| 工布江达县| 晋宁县| 广灵县| 新干县| 潜山县| 丰顺县| 富蕴县| 高阳县| 海宁市| 黎川县| 明光市| 九江市| 合川市| 平湖市| 犍为县| 呼伦贝尔市| 尖扎县| 嘉定区| 琼海市| 泰宁县| 高陵县| 衡山县| 海阳市| 赞皇县| 洛宁县| 阜平县| 乌拉特中旗| 共和县| 长兴县| 清原| 丹巴县| 喀什市| 鄂州市| 闽侯县| 平安县|