简体   繁体   English

通过python tkinter运行shell脚本

[英]Running shell script through python tkinter

I am making an application through python tkinter;我正在通过 python tkinter 制作一个应用程序; I am not able to understand how I can run a shell script with it.我无法理解如何使用它运行 shell 脚本。

My use case is , when I press a button it will invoke a shell script and display its output in GUI.我的用例是,当我按下按钮时,它将调用一个 shell 脚本并在 GUI 中显示其输出。

You're looking for the subprocess module:您正在寻找 subprocess 模块:

https://docs.python.org/3/library/subprocess.html https://docs.python.org/3/library/subprocess.html

An example:一个例子:

subprocess.run(["ls"]). # run ls
output = subprocess.check_output(["ls"]) # grab the output of ls

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

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