satoshi_to_usd.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:cryptocurrency-trader 作者: TobCar 项目源码 文件源码
def current_price_of_bitcoin():
    '''
    Pre: coinmarketcap's api can be accessed. This will require an internet connection.
    Returns: The price of Bitcoin in USD according to coinmarketcap.com
             The variable will be a Decimal with eight decimal places.
    '''
    with localcontext() as context:
        context.prec = 8
        r = requests.get("https://api.coinmarketcap.com/v1/ticker/bitcoin/")
        return Decimal(r.json()[0]["price_usd"])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号