Search code examples
phppythonfilesizemultibyte

Python how to get multibyte variable size in 8-bit?


I am fetching some remote binary file and saving it in the python variable. How can i get its size .i.e size after the file storing on disk ? without actually storing on disk.

In php i am using it like this

<?php
$file_content contains remote downloaded binary file data.
echo mb_strlen($file_content, '8bit');

above code gives file size i.e. file data size stored in variable.

whats the equivalent of it in python ?


Solution

  • The size of the content of a bytes or bytestring is its length.

    >>> len(b'12345')
    5