繁体   English   中英

使用Idle的Python子进程

[英]Python subprocess using Idle

我是python脚本的新手。 我试图在Python Idle上运行子流程方法,并得到以下错误:

import subprocess
subprocess.check_output("ls")

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Users\ramakrishna\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 336, in check_output
  **kwargs).stdout
File "C:\Users\ramakrishna\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 403, in run
  with Popen(*popenargs, **kwargs) as process:
File "C:\Users\ramakrishna\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 707, in __init__
  restore_signals, start_new_session)
File "C:\Users\ramakrishna\AppData\Local\Programs\Python\Python36\lib\subprocess.py", line 990, in _execute_child
  startupinfo)
FileNotFoundError: [WinError 2] The system cannot find the file specified

请帮助我解决此错误。 谢谢

好像您正在运行Windows。 Windows没有“ ls”命令,因此会出现FileNotFoundError异常。 我不熟悉Windows和python,但尝试使用“ dir”而不是“ ls”,应该可以。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM