def get_quantity(entry, default_unit=None):
"""
This function ...
:param entry:
:param default_unit:
:return:
"""
splitted = entry.split()
value = float(splitted[0])
try: unit = splitted[1]
except IndexError: unit = default_unit
# Create a quantity object and return it
if unit is not None: value = value * Unit(unit)
return value
# -----------------------------------------------------------------
评论列表
文章目录