I learn of converting a string to an integer from Python: Convert a string to an integer. But I was still wondering how this works, casting a string consisting of a number following line breaks, like '5\r\n', into int.
>>> int(' \r \n 5 \r \n ')
5
What does Python interpreter do, like this?
>>> s = ' \r \n 5 \r \n '
>>> new_s = s.strip()
>>> int(new_s)
5
intignores heading or trailing whitespace. This is a feature, seehelp(int): The literal can be preceded by '+' or '-' and be surrounded by whitespace.