Skip to content

Instantly share code, notes, and snippets.

@grenzi
Created April 13, 2021 13:02
Show Gist options
  • Save grenzi/f73352c3e87d5ab847896b972a3ccb7a to your computer and use it in GitHub Desktop.
Save grenzi/f73352c3e87d5ab847896b972a3ccb7a to your computer and use it in GitHub Desktop.
import locale, string
n = ['$1,234.56','-$1,234.56','($1,234.56)', '$ -1,234.56']
tbl = str.maketrans('(', '-', '$),')
[locale.atof( x.translate(tbl)) for x in n]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment