[Python] Python: Get size of string in bytes

Discussão em 'Python' iniciado por Stack, Maio 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have a string that is to be sent over a network. I need to check the total bytes it is represented in.

    sys.getsizeof(string_name) returns extra bytes. For example, for sys.getsizeof("a") returns 22, while one character is only represented in 1 byte in Python. Is there some other method to find this?

    Continue reading...

Compartilhe esta Página