使用`os.system`函数
import os
os.system('gnome-terminal -e "python3 /path/to/your/script.py"')
使用`subprocess`模块
from subprocess import Popen
Popen(['open', '-a', 'Terminal', '-n'])
使用`os.startfile`函数(仅适用于Windows):
import os
os.startfile('cmd.exe') 打开命令提示符
os.startfile('powershell.exe') 打开PowerShell
使用`start`命令(仅适用于Windows):
import subprocess
subprocess.call('start /wait python /path/to/your/script.py', shell=True)
使用`open`命令(仅适用于macOS):
import subprocess
subprocess.call(['open', '-a', 'Terminal', '/path/to/your/script.py'])
请根据你的操作系统和需求选择合适的方法。