从PowerShell(.NET)到Python的简单bytesarray转换

2024-09-28 03:25:05 发布

您现在位置:Python中文网/ 问答频道 /正文

如何将PowerShell中的这些代码行转换为Python?你知道吗

$CODEPAGE = "iso-8859-1"
$myFile = "example.exe"
$fileBin = [System.IO.File]::ReadAllBytes($myFile)
$enc = [System.Text.Encoding]::GetEncoding($CODEPAGE)
$fileEnc = $enc.GetString($fileBin)

这些是我到目前为止得到的,有人能告诉我如何将[System.Text.Encoding]::GetEncoding.GetString(bytes)(最后2行)从PowerShell转换为Python吗?非常感谢!你知道吗

CODEPAGE = "iso-8859-1"
myFile = "example.exe"
fileBin = open(myFile, 'rb').read()

Tags: 代码textioexampleisomyfileexesystem

热门问题