num = '654321'
def str_to_int(str):
    val = 0
    for ch in str:
        val *= 10
        val += ord(ch) - ord('0')
    return val
print(str_to_int(num), type(str_to_int(num)))
# 654321 <class 'int'>