我將如何做到以下幾點:子進程刪除文件
subprocess.call(shlex.split('rm {}'.format(os.path.join('/tmp', '*.mp4'))))
基本上,我想刪除我的TMP文件夾中所有的MP4文件。但我得到以下錯誤:
rm: /tmp/*.mp4: No such file or directory
我將如何做到以下幾點:子進程刪除文件
subprocess.call(shlex.split('rm {}'.format(os.path.join('/tmp', '*.mp4'))))
基本上,我想刪除我的TMP文件夾中所有的MP4文件。但我得到以下錯誤:
rm: /tmp/*.mp4: No such file or directory
爲什麼不使用glob?
import glob
import os
for fl in glob.glob("/tmp/*.mp4"):
os.remove(fl)
不需要退出到另一個進程。