The brace expands to the str representation of the object. And the str representation of
You could try to convert your bytestring before inserting, or you could assemble your bytes together directly.
foo
is b'hello'
. So that's what gets inserted.You could try to convert your bytestring before inserting, or you could assemble your bytes together directly.
foo = b'hello' fs = f'{foo.decode()}bar' bfs = fs.encode() print(bfs) foo = b'hello' fs = foo + 'bar'.encode() # Not using f-strings print(fs)