import osos.system("some_command with args");
import osos.system("cat command.py | grep -n subprocess > result.txt")
import osstream = os.popen("some_command with args")
import osstream = os.popen("cat command.py | grep -n subprocess")print(type(stream))result = stream.readlines()print(type(result))print(result)
<class 'os._wrap_close'><class 'list'>['1:import subprocess\n', '2:subprocess.run(["ls", "-l"])\n', '5:subprocess.call(["ls", "-l"])\n', '8:os.system("cat command.py | grep -n subprocess > result.txt")\n']
print(subprocess.Popen("echo Hello World", shell=True, stdout=subprocess.PIPE).stdout.read())
print(os.popen("echo Hello World").read())
import subprocessp = subprocess.Popen('ls', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)for line in p.stdout.readlines(): print(line.decode("utf-8").strip())retval = p.wait()
return_code = subprocess.call("echo Hello World", shell=True)print(return_code)
import subprocessresult = subprocess.run(["ls", "-l"])print(type(result))
import osprint(os.execl('/bin/ls', ' '))
print(subprocess.Popen("echo %s " % user_input, stdout=PIPE).stdout.read())
- EOF -python
2.鴻蒙(HarmonyOS)大神都喜歡玩命令行typescript
3.像極客同樣提取Android的Root權限shell
4.牛掰了!鴻蒙與Android完美融合,將鴻蒙設備當Android設備用
編程
5.【鴻蒙學院】鴻蒙App開發直播學員提問與回答swift
關注「極客起源」公衆號,加星標,不錯過精彩技術乾貨
安全
![](http://static.javashuo.com/static/loading.gif)
本文分享自微信公衆號 - 極客起源(geekculture)。
若有侵權,請聯繫 support@oschina.cn 刪除。
本文參與「OSC源創計劃」,歡迎正在閱讀的你也加入,一塊兒分享。bash