pack an integer into a string

Sebastian Bassi sbassi at clubdelarazon.org
Fri Jul 24 18:43:58 EDT 2009


On Fri, Jul 24, 2009 at 7:28 PM, superpollo<user at example.net> wrote:
> is there a pythonic and synthetic way (maybe some standard module) to "pack"
> an integer (maybe a *VERY* big one) into a string? like this:

What do you mean to pack? Maybe Pickle is what you want.

import cPickle
variable = 124348654333577698
cPickle.dump(variable,open('filename', 'w'))

To load it:

import cPickle
vaariable = cPickle.load(open('filename'))

It is not "into a string", but instead of a filename, use a string with stringio



More information about the Python-list mailing list