Skip to content

Instantly share code, notes, and snippets.

@torokati44
Created December 17, 2021 10:50
Show Gist options
  • Save torokati44/5866f6e9b27190dc219e29fdc71d8a0e to your computer and use it in GitHub Desktop.
Save torokati44/5866f6e9b27190dc219e29fdc71d8a0e to your computer and use it in GitHub Desktop.
import re
import quantities as pq
def parse_quant(s: str):
m = re.match(r"([0-9.,eE+-]+)\s*([a-zA-Z_]*)", s)
return pq.Quantity(float(m.group(1)), m.group(2))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment