执行power shell命令并显示输出
import subprocesscmd = "ls"# cmd1 能够借助power shell保存输出到txt,但是不会显示输出cmd1 = "ls > result.txt"# cmd2 能够借助power shell保存输出到txt,同时显示输出结果cmd2 = "ls > result.txt ; cat result.txt"subprocess.run(["powershell", "-Command", cmd], stdout=sys.stdout)
