Parse Python String for Units

后端 未结 3 1092
灰色年华
灰色年华 2021-02-13 18:12

Say I have a set of strings like the following:

\"5 m^2\"
\"17 sq feet\"
\"3 inches\"
\"89 meters\"

Is there a Python package which will read s

3条回答
  •  迷失自我
    2021-02-13 18:56

    Quantulum will do exactly what you described

    Excerpt from its description:

    from quantulum import parser
    
    quants = parser.parse('I want 2 liters of wine') 
    
    # quants [Quantity(2, 'litre')] 
    

提交回复
热议问题