前提・実現したいこと
subprocessを使って別の外部プログラムを実行しています。
その出力を得ることはできるのですが、まとめて得てtxtに書き出したいです。
該当のソースコード
Python3
1cl.sendMessage(to, "回線速度計測中...") 2p = subprocess.Popen (('speedtest-cli', '--share'), stdout = subprocess.PIPE) 3for l in p.stdout: 4 print = l.strip () 5 #cl.sendMessage(to, str(print)) 6 with open(path, mode='w') as f: 7 f.write(str(print)) 8 with open(path) as f: 9 cl.sendMessage(to, f.read()) 10ret = p.wait () 11cl.sendMessage(to, '正常に計測できました'.format (ret))
どのように書き換えれば実現しますでしょうか。
ご教授よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。