How many bytes long is a string?

Grant Edwards ge at nowhere.none
Tue Aug 8 10:34:47 EDT 2000


In article <398F6EE9.F96AED75 at ix.netcom.com>, Thomas Gagne wrote:

>Hmm.  I need to know how many bytes a String is going to be.  Given
>
>s = "Now is the time"
>
>I would expect one of the following to work (it would seem intuitive...)

len(s) will tell you how many elements (characters) are in
string s.  

However, that is not the same things as "how many bytes". If
you really want to know how many bytes a string object is
taking up in memory, then I don't think theres an easy way to
do that.

-- 
Grant Edwards                   grante             Yow!  If elected, Zippy
                                  at               pledges to each and every
                               visi.com            American a 55-year-old
                                                   houseboy...



More information about the Python-list mailing list