繁体   English   中英

通过python tkinter运行shell脚本

[英]Running shell script through python tkinter

我正在通过 python tkinter 制作一个应用程序; 我无法理解如何使用它运行 shell 脚本。

我的用例是,当我按下按钮时,它将调用一个 shell 脚本并在 GUI 中显示其输出。

您正在寻找 subprocess 模块:

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

一个例子:

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