执行power shell命令并显示输出
import subprocess
cmd = "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)