Is there the same function in python as atoi() in C
Bengt Richter
bokr at oz.net
Sat Aug 2 02:43:19 EDT 2003
On Fri, 01 Aug 2003 20:55:42 -0700, washu <washu at 127.0.0.1> wrote:
>On Sat, 02 Aug 2003 11:51:54 +0800, Robbie wrote:
>
>> Someone tell me,
>> if not exist, how to write one with the same function?
>> I have made a try, but there is no character type in python,
>> so i failed, someone help me,
>> thanks very much
>
>I may be totally wrong but I believe there is a atoi in the strings
>modules.
Easy to check:
>>> import string
>>> help(string.atoi)
Help on function atoi in module string:
atoi(s, base=10)
atoi(s [,base]) -> int
Return the integer represented by the string s in the given
base, which defaults to 10. The string s must consist of one
or more digits, possibly preceded by a sign. If base is 0, it
is chosen from the leading characters of s, 0 for octal, 0x or
0X for hexadecimal. If base is 16, a preceding 0x or 0X is
accepted.
Regards,
Bengt Richter
More information about the Python-list
mailing list