Python string can be converted to int using int(strval). Note that it will throw ValueError for invalid string. Here is a quick example to convert string to int.
s = "7" v = 2 + int(s) print v s = "Invalid int" v = 2 + int(s)
9
Traceback (most recent call last):
File "test.py", line 5, in <module>
v = 2 + int(s)
ValueError: invalid literal for int() with base 10: 'Invalid int'
Env: Python 2.7.18