def str2int(s): def replace_str(s): return s.replace('.', '', len(s)) def str2nums(nums): digits = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9} return digits[nums] def float_(x, y): return x * 10 + y return (reduce(float_, map(str2nums, replace_str(s))))/1000 print(str2int('123.456'))
Sign in to make a reply
愚者长安