Typeerror: a bytes-like Object is required, not 'str'

Asked

Viewed 885 times

-1

I am trying to run an existing program. I have fixed some parts of this program that I think was developed for Vers. 2.x, but I’m trying to run it on 3.6.5. But I came across a line that I can’t assess if there’s a syntax error or what it would be.

This is the line below:

''' % (args.var, args.mexe.split(os.sep)[-1], mexe.replace('\n', ''), args.iexe.split(os.sep)[-1], iexe.replace('\n', ''))

That generates this error: -->

TypeError: a bytes-like object is required, not 'str'

Thank you for your cooperation.

2 answers

0

Is that a string formatting? Replace %operator with . format()

'{} {} {} {} {}'.format(args.var, args.mexe.split(os.Sep)[-1], stir.replace(' n', ''), args.iexe.split(os.Sep)[-1], iexe.replace(' n', ''))

  • Replace your suggestion with the line q was there and then this happened --> "Syntaxerror: EOF while Scanning triple-quoted string literal" by accusing the error in a line after the end of the program. As I have no experience with Python and I’m new here I do not know how to proceed. Could I publish the entire code here p/vc or some other contributor might better understand the problem ?

  • Yes, it will be better.

0

From python2 to python3 strings change the representation of a bit array to the Unicode array.

Your code probably wants a bit array, not a Unicode array, which is the standard string format in python 3.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.