1# '78695' -> 78695 2from functools import reduce 3 4 5def str_to_num(num_str): 6 num_dict = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} 7return reduce(lambda x, y: x * 10 + y, list(map(lambda x: num_dict[x], num_str))) 8 910if__name__ == '__main__': 11print(str_to_num('78695'))