python運行其他程序的實現方法
這里提供了兩種實現方法,一.os.system()函數和 使用ShellExecute函數運行其他程序及實現代碼,大家可以參考下,
一 使用os.system()函數運行其他程序
打開系統的記事本程序
>>>import os>>> os.system('notepad')0>>> os.system('notepad python.txt')0 二 使用ShellExecute函數運行其他程序
>>>import win32api>>> win32api.ShellExecute(0,'open','notepad.exe','','',0)42>>> win32api.ShellExecute(0,'open','notepad.exe','','',1)42>>> win32api.ShellExecute(0,'open','notepad.exe','python.txt','',1)42>>> win32api.ShellExecute(0,'open','http://www.python.org','python.txt','',1)42>>> win32api.ShellExecute(0,'open','E://python//work//Demo.mp3','','',1)42>>> win32api.ShellExecute(0,'open','E://python//work//MessageBox.py','','',1)42
感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!
新聞熱點
疑難解答