figuring out # of bytes
Jaime Wyant
programmer.py at gmail.com
Mon Apr 25 08:44:44 EDT 2005
On 4/22/05, Jaime Wyant <programmer.py at gmail.com> wrote:
> On 22 Apr 2005 13:28:57 -0700, codecraig <codecraig at gmail.com> wrote:
> > i want to the number of bytes in a string...
> >
> > is, len(x) accurate?
> >
> > so, x = "hi"
> > len(x) == 2 ....so that means two bytes?
> >
> > thanks
>
> No, that means that the string is two bytes in length. The number of
> bytes is dependent on the encoding. It seems like there was a thread
> on this subject recently.
Ughh, i misstated. More correctly, the string is 2 "characters" in
length. The number of bytes per character depends on the encoding.
jw
More information about the Python-list
mailing list