Skip to content

Instantly share code, notes, and snippets.

@fmasanori
Created May 29, 2019 12:48
Show Gist options
  • Save fmasanori/c2ded3f71898403732501dc3b10676b2 to your computer and use it in GitHub Desktop.
Save fmasanori/c2ded3f71898403732501dc3b10676b2 to your computer and use it in GitHub Desktop.
Conversão Monetária
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1.003.353.635,34 <class 'str'>\n"
]
}
],
"source": [
"import locale\n",
"locale.setlocale(locale.LC_ALL, '')\n",
"valor = 1003353635.34\n",
"valor = locale.currency(valor, grouping=True,\n",
" symbol=None)\n",
"print (valor, type(valor))"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"1003353635.34 <class 'float'>\n"
]
}
],
"source": [
"valor = locale.atof(valor)\n",
"print (valor, type(valor))"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment