0

Hello is there a way to convert string to bytes like this "b'\x..."?

I have tried:

string = "mystring"
print(string.encode('utf-8'))

But I get

b'mystring'

I want it to print like

b'\x...
  • Here is [a good discussion](https://stackoverflow.com/questions/7585435/best-way-to-convert-string-to-bytes-in-python-3) on this topic that hopefully answers your questions. – rhurwitz Feb 07 '23 at 16:47

0 Answers0