Пример #1
0
def u(amount):
    units = ''.join([c for c in amount if c in string.ascii_letters])
    units = units.lower()
    number_string = ''.join([c for c in amount if c in digit_chars])
    if '.' in number_string:
        number = float(number_string)
    else:
        number = int(number_string)
    multiplier = unit_lookup.get(units, 1)
    return number * multiplier
Пример #2
0
def u(amount):
    units = ''.join([c for c in amount if c in string.ascii_letters])
    units = units.lower()
    number_string = ''.join([c for c in amount if c in digit_chars])
    if '.' in number_string:
        number = float(number_string)
    else:
        number = int(number_string)
    multiplier = unit_lookup.get(units, 1)
    return number * multiplier