简体   繁体   English

使用Idle的Python子进程

[英]Python subprocess using Idle

I am new to python scripting. 我是python脚本的新手。 I am trying to run subprocess methods on Python Idle and getting these errors: 我试图在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

Please help me out to resolve this error. 请帮助我解决此错误。 Thank you 谢谢

seems like you are running windows. 好像您正在运行Windows。 Windows has no "ls" command, so you get a FileNotFoundError exception. Windows没有“ ls”命令,因此会出现FileNotFoundError异常。 I am not familiar with windows and python, but try "dir" instead of "ls", that should work. 我不熟悉Windows和python,但尝试使用“ dir”而不是“ ls”,应该可以。

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

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