LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-27-2005, 10:23 AM   #1
Kanaflloric
Member
 
Registered: Jun 2004
Location: Canada
Distribution: Slackware 10.0
Posts: 80

Rep: Reputation: 15
convert string to integer with python


Hi

Does anyone know how to convert a string (ex: '21') to an integer (21) ?
I had a look to atoi() function, but it doesnt seem to exist anymore...
 
Old 05-27-2005, 10:35 AM   #2
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
Re: convert string to integer with python

Quote:
Originally posted by Kanaflloric
Does anyone know how to convert a string (ex: '21') to an integer (21) ?
I had a look to atoi() function, but it doesnt seem to exist anymore...
Code:
heiko@hko:~$ python
Python 2.3.5 (#2, May  4 2005, 08:51:39) 
[GCC 3.3.5 (Debian 1:3.3.5-12)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> str = "102"
>>> str
'102'
>>> int(str) + 3
105
 
Old 05-27-2005, 11:04 AM   #3
Kanaflloric
Member
 
Registered: Jun 2004
Location: Canada
Distribution: Slackware 10.0
Posts: 80

Original Poster
Rep: Reputation: 15
I have tried almost every combinaison ( integer('20'), str.integer(), ...) except this one ! :-(

thanks
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
C++ string to integer conversion fatman Programming 6 06-18-2006 08:17 AM
C how to convert an integer to string? totti10 Programming 10 11-10-2005 05:49 AM
Integer To a String in C Bean101 Programming 2 05-27-2004 04:46 AM
How do you convert a string to an integer? wbdune Linux - Newbie 11 11-01-2003 02:01 PM
convert integer to string (atoi?) lea Programming 6 10-11-2002 05:16 PM


All times are GMT -5. The time now is 06:22 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration