The
b
in front of the quotes tells Python that these are bytes.
If you don't assign the result to a name, the REPL prints the object in its representation form, which also includes the quotes.
If you
decode
the bytes to a
str
, then the quotes are only shown in representation (without the leading b).
If you print the resulting str, you won't see the quotes at the start and end of the str, but if you print bytes, then the representation is printed to console.
data = b"123" # bytes
print("bytes", data)
print("str", data.decode())
# decode without encoding, will use the system default encoding
# it's motsly everywhere uft8
# sometimes it's latin1 (in old Windows Terminal e.G.)
Output:
bytes b'123'
str 123