I am trying to split an UTF-8 string into bytes in python 3. The problem is, when I use bytearray, byte, encode etc functions I always get an array with size of element 14 bytes, not 1 byte as I expected. I need to split any text file into sequence of bytes and send them byte after byte using sockets. I tried something like this:
infile = open (file, "r")
str = infile.read()
byte_str = bytes(str, 'UTF-8')
print("size of byte_str",sys.getsizeof(byte_str[0]))
Print gives me 14, but I need 1... Any suggestion?
rbto get a bytes object from read.