checked_system.py

来自「Boost provides free peer-reviewed portab」· Python 代码 · 共 23 行

PY
23
字号
import osimport stringimport sysdef system( commands ):    if sys.platform == 'win32':        f = open( 'tmp.cmd', 'w' )        f.write( string.join( commands, '\n' ) )        f.close()        rc = os.system( 'tmp.cmd' )        return rc    else:        rc = os.system( '&&'.join( commands ) )        return rc    def checked_system( commands, valid_return_codes = [ 0 ] ):    rc = system( commands )     if rc not in [ 0 ] + valid_return_codes:        raise Exception( 'Command sequence "%s" failed with return code %d' % ( commands, rc ) )    return rc

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?