python 2 into python 3 : Hello I am just beginner, and run into problem while trying some codes:

    os_name = os_info.Name.encode('utf-8').split('|')[0]

Error:

    a bytes-like object is required, not 'str'
I found out that there could be problem that I use Python3.7
Could not contact owner of the code, due to lack of "reputation" (new acc), so I am posting it here.