1

I thought 'b' and 'encode' were the same method to convert a string to a bytes flow before ,but I try follow today

print("\x08\x04\x86\x3B".encode())
print(b"\x08\x04\x86\x3B")

the result is

b'\x08\x04\xc2\x86;'
b'\x08\x04\x86;'

why encode method insert '\xc2' in string? what difference between 'b' and 'encode' to convert a string to a byte flow in python? my environment is python3.8

Squirre17
  • 19
  • 2

0 Answers0