简体   繁体   中英

run os.system commands on a new terminal- Python 3

I am running a program which allows me to run terminal commands through my Python code which takes input from the user through the command line. This is the part of the code where I open Google-Chrome

import sys
import os 
os.system("google-chrome") #I have Ubuntu 16.04

It opens the browser but the problem is that the terminal on which my python code is running becomes the same as the one where Chrome is running which means that I cannot give further input to my Python code. To solve this problem I need the Chrome to run as a process on a different terminal. I tried using subprocess.call("google-chrome", shell=True) but it did not open it on a new terminal.

How do I make the process run on a different terminal?

这可以解决您的问题吗?

os.system('gnome-terminal -x chromium-browser')

Use subprocess.popen("command")

Basically, run the subprocess in the background. & is a shell feature. Use popen instead

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM