

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to parse a string to float or int in python?
To parse a string to int, you can use the following:
try: print int('112') except ValueError: print 'Cannot parse'
This will give you the output:
112
To parse a string to float, you can use the following:
try: print float('112.15') except ValueError: print 'Cannot parse'
This will give you the output:
112.15
- Related Questions & Answers
- How to parse a string to an int in C++?
- How to parse a string into a nullable int in C#?
- How can I parse a numeric string to its corresponding float value?
- How to convert int to string in Python?
- How to parse float with two decimal places in JavaScript?
- How to convert hex string into int in Python?
- How to check if a string can be converted to float in Python?
- How to parse a string from a JavaScript array?
- How to parse json string in android?
- How to convert a Java String to an Int?
- How to convert a String to an int in Java
- How to convert a string to int in Lua programming?
- How to convert a string into int in C#?
- How to convert a String into int in Java?
- How to convert int to String in java?
Advertisements