Reputation: 169
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('=')
Upvotes: 9
Views: 8689
Reputation: 10736
Another solution is adding text=True
to check_output
:
path = os.getcwd().strip('/n') Null,userprof = subprocess.check_output('set USERPROFILE', shell=True, text=True).split('=')
Upvotes: 0
Reputation: 4067
Decode before using split
funtion
Null,userprof = subprocess.check_output('set USERPROFILE', shell=True).decode('utf-8').split('=')
Upvotes: 13