#author("2022-10-12T15:11:07+09:00","default:tosiaki","tosiaki")
#author("2022-10-12T16:56:33+09:00","default:tosiaki","tosiaki")
[[書き比べスクリプト・リファレンス]]



* Python [#wc2868c8]

os.system は古い方式で、今後は subprocess に置き換わる


run() でコマンドも含め、引数を配列で渡す

 import subprocess
 
 subprocess.run(['ls', '-l'])

Python側でコマンドの出力結果を取得するには、run()関数に「capture_output=True」を指定
※ python 3.7 以降

 cp 
 = subprocess. run()
 
 cp.stdout  標準出力 
 cp.stderr  標準エラー出力

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS