python3typeerror:只能将str(而不是“bytes”)连接到s

2024-10-01 07:23:00 发布

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

我有这个错误的代码,找不到修复程序。在

49         os.system('powershell -enc 
    '+base64.b64encode(addpermissions.encode('utf_16_le')))   
    . 
    .
    .
     137 HexRegHash, HexRegSysk, jd, skew1, gbg, data = getRegistryValues(HexRID)

我有个错误:

^{pr2}$

Tags: 代码程序leos错误systemutfencode
1条回答
网友
1楼 · 发布于 2024-10-01 07:23:00

base64.b64encode生成字节流,而不是字符串。因此,为了使连接生效,必须先用str(base64.b64encode(addpermissions.encode('utf_16_le')))将其转换为字符串

b64cmd = base64.b64encode(cmd.encode('utf_16_le')).decode('utf-8')
os.system('powershell -enc ' + b64cmd)

编辑:普通字符串转换不适用于操作系统,改为使用decode('utf-8')

相关问题 更多 >