Discuss / Python / 一行到底

一行到底

Topic source

风袭6729

#1 Created at ... [Delete] [Delete and Lock User]

实际使用时,这样应该不好吧

DIGITS = {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9}

    return reduce(lambda x, y:x * 10 + y, map(lambda x:DIGITS[x], s.split('.')[0])) + reduce(lambda x, y:x * 10 + y, map(lambda x:DIGITS[x], s.split('.')[1])) / (10 ** len(s.split('.')[1]))

  • 1

Reply