`
cakin24
  • 浏览: 1335349 次
  • 性别: Icon_minigender_1
  • 来自: 西安
社区版块
存档分类
最新评论

python运行其他程序

阅读更多

一 使用os.system()函数运行其他程序

打开系统的记事本程序
  1. >>>import os
  2. >>> os.system('notepad')
  3. 0
  4. >>> os.system('notepad python.txt')
  5. 0
 
二 使用ShellExecute函数运行其他程序
  1. >>>import win32api
  2. >>> win32api.ShellExecute(0,'open','notepad.exe','','',0)
  3. 42
  4. >>> win32api.ShellExecute(0,'open','notepad.exe','','',1)
  5. 42
  6. >>> win32api.ShellExecute(0,'open','notepad.exe','python.txt','',1)
  7. 42
  8. >>> win32api.ShellExecute(0,'open','http://www.python.org','python.txt','',1)
  9. 42
  10. >>> win32api.ShellExecute(0,'open','E:\\python\\work\\Demo.mp3','','',1)
  11. 42
  12. >>> win32api.ShellExecute(0,'open','E:\\python\\work\\MessageBox.py','','',1)
  13. 42
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics