我正在嘗試獲取進程的時間,當我在 shell 中使用關鍵字 time 時,我得到了更好的輸出:real 0m0,430suser 0m0,147ssys 0m0,076s而不是 which/usr/bin/time給出了不同的輸出。當我嘗試通過 python 的子進程庫運行它時,subprocess.call('time command args',shell=True)它給了我 /usr/bin/time 而不是關鍵字。我如何使用關鍵字函數而不是當前函數?
1 回答

撒科打諢
TA貢獻1934條經驗 獲得超2個贊
shell=True
導致subprocess
使用/bin/sh
,不bash
。executable
你也需要論據
subprocess.call('time command args', shell=True, executable='/bin/bash')
bash
根據需要調整路徑。
添加回答
舉報
0/150
提交
取消