Discuss / Python / 交作业

交作业

Topic source

杨佳锋_Tim

#1 Created at ... [Delete] [Delete and Lock User]
def char2num(c):
    return {'0': 0, '1': 1, '2': 2, '3': 3, '4': 4, '5': 5, '6': 6, '7': 7, '8': 8, '9': 9,'.':'.'}[c]
def fn(x,y):
    if y=='.':
        return x
    else:
        return x*10+y
return reduce(fn,map(char2num,s))/pow(10,len(s.split('.')[1]))

  • 1

Reply