- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- 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
Advertisements