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

-1

I'm trying to make an existing program work. I have corrected some parts of this program that I believe was developed for Vers. 2.x, but I'm trying to run it in 3.6.5. But I came across a line that I can not evaluate if there is 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'

Thanks in advance for your cooperation.

    
asked by anonymous 27.05.2018 / 22:59

2 answers

0

Is this a string formatting? Replace the% operator with the .format () function.

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

    
28.05.2018 / 00:26
0

From python2 to python3 the strings have changed the representation of an array of bits to the unicode array.

Your code probably wants an array of bits instead of unicode which is the default string format in python 3.

    
28.05.2018 / 17:06