如何在 Python 中使用 dir/s 命令? [英] How to use the dir/s command in Python?
本文介绍了如何在 Python 中使用 dir/s 命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
背景
我一直在批处理文件中使用命令 dir/s
.但是,我无法使用 python 调用它.注意:我使用的是 Python 2.7.3.
I use the command dir/s
in batch files all the time. But, I am unable to call this using python. NOTE: I am using Python 2.7.3.
代码
import subprocess
subprocess.call(["dir/s"])
错误信息
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
subprocess.call(["dir/s"])
File "C:\Python27\lib\subprocess.py", line 493, in call
return Popen(*popenargs, **kwargs).wait()
File "C:\Python27\lib\subprocess.py", line 679, in __init__
errread, errwrite)
File "C:\Python27\lib\subprocess.py", line 896, in _execute_child
startupinfo)
WindowsError: [Error 2] The system cannot find the file specified
我曾尝试更改引文,但没有任何效果.
I have tried changing the quotations but nothing has worked.
如何使用 subprocess
调用 dir/s
模块?
How would I call the dir/s
module using subprocess
?
推荐答案
怎么样
subprocess.call("dir/s", shell=True)
未验证.
这篇关于如何在 Python 中使用 dir/s 命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文