如何使用python脚本在linux上运行应用程序?

2024-05-21 04:13:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我必须在Linux机器上定期使用多个类似的应用程序,所以我想编写一个脚本来打开它们。你知道吗

你能帮我写一个脚本一次打开多个应用程序吗。你知道吗

示例:Firefox和Libre office cal

你能推荐一个能打开以上应用程序的脚本吗(Firefox和Libre office cal),这样我就可以定制脚本来打开多个应用程序了。你知道吗

脚本:

import os
import browser
from threading import Thread

def app1(my_app_name):

  os.system(my_app_name)


def main():
 t1 = Thread(target=app1, args=(('firefox',)) )
 #t2 = Thread(target=app1 , args=(('libreoffice',)) )
 t1.start()
 #t2.start()


if __name__ == '__main__':
 main()

Tags: nameimport脚本app应用程序osmainmy
1条回答
网友
1楼 · 发布于 2024-05-21 04:13:45

也许有用:

import os
from threading import Thread

def app1(my_app_name):

  os.system(my_app_name)


def main():
 t1 = Thread(target=app1, args=(('firefox',)) )
 t2 = Thread(target=app1 , args=(('libreoffice',)) )
 t1.start()
 t2.start()


if __name__ == '__main__':
 main()

我使用(os)来执行linux命令shell(也可以在windows中使用) 和线程以并行方式运行程序

相关问题 更多 >