Discuss / Python / 第三题

第三题

Topic source
在此插入代码

def str2int(s): name = s.split('.') past = name[0] last = name[1]

def char2inum(num):
    return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7
, '8': 8, '9': 9}[num]
def fn_1(x, y):
    return 10*x+y
def fn_2(x, y):
    return 1
m_list = list(map(char2inum,past)) + list(map(char2inum,last))
return reduce(fn_1,m_list)*pow(10,-len(last))

  • 1

Reply