我一直在尝试以下方法:
process=check_output(["powershell.exe", "Get-Childitem C:\\Windows\\*.log"]);
return process
它返回时输出:
b'\r\n\r\n Directory: C:\Windows\r\n\r\n\r\nMode LastWriteTime Leng th Name \r\n---- ------------- - ----- ---- \r\n-a---- 6/14/2018 11:26 AM 4056 DtcInstall.log \r\n-a---- 6/21/2018 11:33 AM 41261 iis.log \r\n-a---- 9/12/2016 4:34 AM 1342 lsasetup.log \r\n-a---- 6/25/2018 12:06 PM 8904 PFRO.log \r\n-a---- 6/21/2018 12: 04 PM 7530 setupact.log \r\n-a---- 9/12/2016 4:35 AM 0 setuperr.log \r\n-a---- 6/26/201 8 12:17 PM 275 WindowsUpdate.log \r\n\r\n\r\n'
到处都是\n和\r。如何让它返回所需的标准格式?我还用.PIPE尝试了subprocess Popen方法,得到了相同的结果。你知道吗
结果是一个编码的bytestring,您必须首先
.decode()
它,然后print()
它才能看到它的格式。\r\n
是字符串中的换行符。你知道吗相关问题 更多 >
编程相关推荐