dire che ho un insieme di stringhe come la seguente:Parse Python String per unità
"5 m^2"
"17 sq feet"
"3 inches"
"89 meters"
C'è un pacchetto di Python, che leggerà queste stringhe, convertirli in SI, e restituire il risultato in un facilmente- forma utilizzabile? Ad esempio:
>>> a=dream_parser.parse("17 sq feet")
>>> a.quantity
1.5793517
>>> a.type
'area'
>>> a.unit
'm^2'
https://pypi.python.org/pypi/units è buono, ma non credo che analizzerà le unità di una stringa per te. – mgilson
Eccone un altro: https://pint.readthedocs.org/en/latest/ – isedev
possibile duplicato di [libreria Python per convertire tra prefissi unità SI] (http://stackoverflow.com/questions/10969759/python-library- to-convert-between-si-unit-prefixes) –