Skip to main content

货币汇率转换

Project description

The Money Converter

Python汇率转换工具类,数据来源于themoneyconverter

快速入门

安装

pip install themoneyconverter

使用

from themoneyconverter import MoneyConverter, Currency


if __name__ == '__main__':
    # 获取1元人民币转换其它货币的汇率
    moneyConverter = MoneyConverter(Currency.CNY.name)
    moneyConverter.refresh()
    rate = moneyConverter.get_rate(Currency.ARS.name)
    print(Currency.ARS.value, rate)

执行结果示例

Connected to pydev debugger (build 203.7717.81)
阿根廷比索 30.9827

Process finished with exit code 0

代码说明

class MoneyConverter:
    URL_TEMPLATE = 'https://themoneyconverter.com/zh-CN/{source}/{target}?amount=1.00'

    def __init__(self, source='CNY', target='CNY'):
        self.rate = {}
        self.source = source
        self.target = target
        self.updateTime = None

source是转出货币,target是转入货币,比如说moneyConverter = MoneyConverter(Currency.CNY.name)是1元人民币转换其它货币的汇率,target用默认值即可,目前没什么用

支持以下货币汇率互相转换

  • AED = 阿联酋迪拉姆
  • JPY = 日元
  • ARS = 阿根廷比索
  • KRW = 韩元
  • AUD = 澳元
  • MAD = 摩洛哥迪拉姆
  • BRL = 巴西雷亚尔
  • MXN = 墨西哥比索
  • CAD = 加元
  • NOK = 挪威克朗
  • CHF = 瑞士法郎
  • NZD = 新西兰元
  • CNY = 人民币
  • PHP = 菲律宾比索
  • CZK = 捷克克朗
  • PLN = 波兰兹罗提
  • DKK = 丹麦克朗
  • RUB = 俄罗斯卢布
  • EUR = 欧元
  • SEK = 瑞典克朗
  • GBP = 英镑
  • SGD = 新加坡元
  • HKD = 港元
  • THB = 泰铢
  • HUF = 匈牙利福林
  • TRY = 土耳其里拉
  • ILS = 以色列谢克尔
  • USD = 美元
  • INR = 印度卢比
  • ZAR = 南非南特

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

the-money-converter-1.0.1.tar.gz (4.2 kB view details)

Uploaded Source

File details

Details for the file the-money-converter-1.0.1.tar.gz.

File metadata

  • Download URL: the-money-converter-1.0.1.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.7

File hashes

Hashes for the-money-converter-1.0.1.tar.gz
Algorithm Hash digest
SHA256 31e61a0188e5e6b0a9f16bba649c06597bcca559be86cd85c4eb0bcdda01d45a
MD5 7e3e0760fb7beca216baad60116bb773
BLAKE2b-256 ea2b10764e0f41aee6eeb30db2f6774ad8b625fe8736f65e35a11bf3517aa814

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page