Does anybody have a quickie for converting an unsafe string to an int?
int
The string typically comes back as: \'234\\r\\n\' or something like
\'234\\r\\n\'
import re int(re.sub(r'[^\d-]+', '', your_string))
This will strip everything except for numbers and the "-" sign. If you can be sure that there won't be ever any excess characters except for whitespace, use gruszczy's method instead.