import os
os.system('notepad python.txt')
ShellExecute(hwnd,op,file,params,dir,bShow)
- hwnd
:父窗口的句柄,若没有则为0
- op
:要进行的操作,为open,print or 空
- file
:要运行的程序或脚本
- params
: 要向程序传递的参数,如果打开的是文件则为空
- dir
:程序初始化的目录
- bShow
:是否显示窗口
ShellExecute(0, 'open', 'notepad.exe', 'python.txt', '', 1)
ShellExecute(0,'open','http://www.baidu.com','','',1)
ShellExecute(0,'open','F:\\Love\\Lady Antebellum - Need You Now.ape','','',1)
ShellExecute(0,'open','D:\Python\Code\Crawler\HanhanBlog.py','','',1)
import win32process
from win32process import CreateProcess
CreateProcess('c:\\windows\\notepad.exe', '', None, None, 0,
win32process.CREATE_NO_WINDOW, None, None,
win32process.STARTUPINFO())