May-10-2020, 03:22 AM
Quote:tn.write(b"int loopback " + str(n) + "\n")
The expression you have in the argument is a bytestring, a str, and a str, all added together. But you can't add bytestrings and strs.
>>> b"foo" + "foo" Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: can't concat str to bytesIf whatever you need to feed bytes to needs UTF-8, then you should generally
encode
your str to turn it into bytes.>>> b"foo" + "foo".encode() b'foofoo'