Discuss / Python / 没有直接用float

没有直接用float

Topic source

哒哒大萌

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

def str2num(s):

    s1 = s.split('.')

    if len(s1) == 1:

        s1.append('0')

    return int(s1[0]) + int(s1[1]) / (10 * len(s1[1]))


  • 1

Reply