本文介绍了从python打开一个终端的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个带有按钮的程序.按下后,我想打开一个运行的终端:
I'm developing a program that has a button. When pressed, I want to open a terminal that runs:
sudo apt-get update
我正在使用:
os.system("gnome-terminal -e 'sudo apt-get update'")
这很好用.唯一的问题是更新完成后,终端会关闭.我该怎么做才能让终端保持打开状态?
This works fine. The only problem is that when the update is finished, the terminal closes.What can I do to leave the terminal open?
推荐答案
你可以这样做:
os.system("gnome-terminal -e 'bash -c \"sudo apt-get update; exec bash\"'")
这篇关于从python打开一个终端的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!