enthuguy
asked on
python convert currency
Hi Python experts,
Trying to convert an amount from USD to AUD
I tried below using interactive python and it worked
However, trying to incorporate this into a python file but getting an error
convert.py
Traceback (most recent call last):
File "/usr/local/bin/aws_cost_e xplorer.py ", line 6, in <module>
import CurrencyConverter
ImportError: No module named CurrencyConverter
please help
Trying to convert an amount from USD to AUD
I tried below using interactive python and it worked
pip install --user currencyconverter
$ python
Python 2.7.5 (default, Aug 7 2019, 00:51:29)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux2
>>> from currency_converter import CurrencyConverter
>>> c = CurrencyConverter()
>>> c.convert(100, 'USD', 'AUD')
146.9260630134513
However, trying to incorporate this into a python file but getting an error
convert.py
#!/usr/bin/env python3
import argparse
import boto3
import datetime
from currency_converter import CurrencyConverter
Traceback (most recent call last):
File "/usr/local/bin/aws_cost_e
import CurrencyConverter
ImportError: No module named CurrencyConverter
please help
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
print(dtemplate.format(res ult_by_tim e['TimePer iod']['Sta rt'], group['Keys'][0], group['Keys'][1], c.convert(float(amount), 'USD', 'AUD'), unit, result_by_time['Estimated' ]))
assuming c.convert takes in float and returns float.
assuming c.convert takes in float and returns float.
ASKER
any suggestion on this one please. trying to convert amount value. how to use convert ?
print(dtemplate.format(res