open a terminal from python

前端 未结 4 1985
夕颜
夕颜 2021-02-01 22:42

I\'m developing a program that has a button. When pressed, I want to open a terminal that runs:

sudo apt-get update

I\'m using:



        
4条回答
  •  南方客
    南方客 (楼主)
    2021-02-01 23:26

    import os

    os.system("Your command") You can also pass custom command as custom variable For example:

    cmd_to_run = "ls -lat"

    os.system(cmd_to_run)

提交回复
热议问题