TypeError:需要类似字节的对象,而不是subprocess.check_output中的'str'

Abh*_*ran 5 python subprocess python-3.x

我得到TypeError:需要一个类似字节的对象,而不是python3.5中以下代码行中的'str'.

path = os.getcwd().strip('/n')
Null,userprof = subprocess.check_output('set USERPROFILE', shell=True).split('=')
Run Code Online (Sandbox Code Playgroud)

Raj*_*jez 9

在使用split函数之前解码

Null,userprof = subprocess.check_output('set USERPROFILE', shell=True).decode('utf-8').split('=')
Run Code Online (Sandbox Code Playgroud)