python as a “batch” script (i.e. run commands from python)

后端 未结 4 1292
花落未央
花落未央 2020-12-30 08:50

I\'m working in a windows environment (my laptop!) and I need a couple of scripts that run other programs, pretty much like a windows batch file.

how can I run a com

4条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-30 09:13

    os.execlp should work. This will search your path for the command. Don't give it any args if they're not necessary:

    >>> import os
    >>> os.execlp("cmd")
    
    D:\Documents and Settings\Claudiu>Microsoft Windows XP [Version 5.1.2600]
    (C) Copyright 1985-2001 Microsoft Corp.
    
    D:\Documents and Settings\Claudiu>
    

提交回复
热议问题