8
votes

I am getting TypeError: a bytes-like object is required, not 'str' in the following line of code in python3.5.

path = os.getcwd().strip('/n')
Null,userprof = subprocess.check_output('set USERPROFILE', shell=True).split('=')
1

1 Answers

12
votes

Decode before using split funtion

Null,userprof = subprocess.check_output('set USERPROFILE', shell=True).decode('utf-8').split('=')