GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing tracholar.github.io — Python Subprocess - Tracholar的个人wiki Python Subprocess
Table of Contents
处理子进程, 可以替代 参考: 基本函数
subprocess.call('ls -l', shell=True) subprocess.call(['ls', '-l']) subprocess.Popen('ls -l', shell=True) subprocess.Popen(['ls', '-l'])
# 读取子进程的stdout p = subprocess.Popen('ls -l', shell=True, stdout=subprocess.PIPE) print p.stdout.read() # 发送数据给子进程的stdin p = subprocess.Popen('cat', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE) stdout, stderr = p.communicate('data1\ndata2\ndata3')
from subprocess import * output = check_output(["mycmd", "myarg"]) # output=`mycmd myarg` created in 2019-02-20
|
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |