如何同时在命令window和文本文档中获取流输出

How to get stream output in command window and text document simultaneously

使用os.system('ping 127.0.0.1 -t >> new.txt')。我能够在 new.txt 文档中获得 ping 结果。如何在命令 window 和文本文件 中同时获得 ping 结果 在这样的流输出的情况下...?

适用于 os.system('powershell "ping 127.0.0.1 -t | tee ping.txt')