在Python脚本中运行命令行 [英] Running command lines within your Python script

查看:868
本文介绍了在Python脚本中运行命令行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我有一堆别名和命令行提示程序,我的主程序工作通过输入b到cmd.exe,其次是一些文件路径名称和什么不。我将如何在我的python脚本中运行这些参数?

So I have a bunch of aliases and Command Line prompt programs, and my main program works by inputting b into the cmd.exe, followed by some filepath names and what not. How would I run those arguments in my python script? So that it mimics the action i am doing in the cmd?

推荐答案

你应该使用 subprocess 模块。特别是, subprocess.call 将为您运行命令行程序。

You should use the subprocess module. In particular, subprocess.call will run command line programs for you.

这篇关于在Python脚本中运行命令行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆