I need to convert a string with bytes (string view) to byte object in Python.
string = input() # string = '\xff\x00B'
bs = samefunc(string) # typeof(bs) == bytes, len(bs) == 3
print(bs[0]) # b'\xff'
print(bs[1]) # b'\x00'
print(bs[2]) # b'B'
In my app the string input is so large the self parser will be very slow.
bsis a bytes object,bs[0]will be 255, notb'\xff', if that matters.bsis bytestring, andbs[0] == 255. Self parser is a selfwrite function, which parse string to normal symblos and\xXXconstructions.