tee chwee liong wrote:
hi,
is there a way to convert from string to long?
my_string = "1234"
my_long = long(my_string)
We're happy to help you, but you should make some effort to help
yourself. Have you worked through the Python tutorial? Don't just *read*
it, actually follow the instructions and *do* it.
From Python 2.5 on, the function int() will do the same thing and
there's never any reason to use long(). From Python 3, long() is removed.
int() (and long) also take an optional second argument, the base to use:
>>> int("11") # decimal by default
11
>>> int("11", 2) # binary
3
--
Steven
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor