This question already has answers here:
Python subprocess Popen: Why does “ls *.txt” not work? [duplicate]
(2个答案)
三年前关闭。
>>> import subprocess
>>> child = subprocess.Popen(["ls", "examples/*"], stdout=subprocess.PIPE)
>>> ls: examples/*: No such file or directory

但从终点站开始
Beagle:kumarshubham$ ls examples/*
examples/convert_greyscale.py       examples/feat_det_harris_corner.py  examples/read_display_image.py
examples/example_set_roi.py     examples/manipulate_img_matplotlib.py   examples/remove_matplotlib_cache.py

有人能告诉我哪里做错了吗?

最佳答案

import subprocess
child = subprocess.Popen(["cd /to-your-PATH/; ls", "examples/*"],shell=True, stdout=subprocess.PIPE)
child.stdout.read()

关于python - 子进程ls示例/*无此类文件或目录,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/37026214/

10-11 19:37