Python: Convert a string to an integer
Posted
by Adam Nelson
on Stack Overflow
See other posts from Stack Overflow
or by Adam Nelson
Published on 2010-03-24T15:17:04Z
Indexed on
2010/03/24
15:23 UTC
Read the original article
Hit count: 324
python
Does anybody have a quickie for converting an unsafe string to an int?
The string typically comes back as: '234\r\n' or something like that.
In this case I want 234. If '-1\r\n', I want -1. I never want the method to fail but I don't want to go so far as try, except, pass just to hide errors either (in case something extreme happens).
© Stack Overflow or respective owner