To str python. to_bytes (len (b) // 8, 'big') turns it into a byte sequence. ...