37,743
社区成员




class PathTraveller:
def __init__(self, path):
subprocess.call(["bash -c 'pushd abc'"], shell = True);
def __del__(self):
subprocess.call(["bash -c 'popd'"], shell = True);
def execute(self, cmd):
subprocess.call([cmd]);
def main():
x = PathTraveller("abc");
x.execute("pwd");
import os
st = os.system("命令")
#st返回0【成功】或1【失败】
f_s = os.popen("命令")
#f_s为命令返回结果的文件对象【查看用f_s.read()或者readline、readlines...等文件对象操作方法】