我一直在尝试如何通过将和分配给值来不打印Python的shell输出:subprocess.call()open(os.devnull, 'w')subprocess.PIPEstdout
subprocess.call(command, stdout=open(os.devnull, 'w'), shell=True)
Run Code Online (Sandbox Code Playgroud)
和
subprocess.call(command, stdout=subprocess.PIPE, shell=True)
Run Code Online (Sandbox Code Playgroud)
这两行都command谨慎地执行存储在变量中的 shell 命令,即不在终端上输出。但是,我不知道两者之间的区别。我刚开始使用subprocess.
/ogs