faqts : Computers : Programming : Languages : Python : Snippets : Strings

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 13 people (38%) answered Yes
Recently 3 of 10 people (30%) answered Yes

Entry

Pack, unpack format strings

Jul 5th, 2000 10:03
Nathan Wallace, unknown unknown, Hans Nowak, Snippet 308, Chris Tavares


"""
Packages: maths.bases;basic_datatypes.strings
"""
"""
> > Is there a way to read and write base-n strings using pack or unpack.  i.e.
> > if I have a string '1001001011' and I tell it to read a 10-digit binary
> > string, it would return 587.  If not using pack or unpack, is there another
> > way to do it?
"""
import string
print string.atoi('1001001011', 2)
# 587