【发布时间】:2021-06-28 18:15:10
【问题描述】:
我正在通过 python tkinter 制作应用程序;我无法理解如何使用它运行 shell 脚本。
我的用例是,当我按下一个按钮时,它会调用一个 shell 脚本并在 GUI 中显示它的输出。
【问题讨论】:
标签: python shell tkinter python-requests tkinter-entry
我正在通过 python tkinter 制作应用程序;我无法理解如何使用它运行 shell 脚本。
我的用例是,当我按下一个按钮时,它会调用一个 shell 脚本并在 GUI 中显示它的输出。
【问题讨论】:
标签: python shell tkinter python-requests tkinter-entry
您正在寻找子流程模块:
https://docs.python.org/3/library/subprocess.html
一个例子:
subprocess.run(["ls"]). # run ls
output = subprocess.check_output(["ls"]) # grab the output of ls
【讨论】: