V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
katyang
V2EX  ›  Python

把英制转换成公制的 python 工具?

  •  
  •   katyang · 2016-09-27 19:58:09 +08:00 · 3010 次点击
    这是一个创建于 2765 天前的主题,其中的信息可能已经有所发展或是发生改变。
    要进行一些文字处理
    有没有什么现成的工具,可以把英制转换称公制,
    把美元转换成人民币的?
    谢谢
    6 条回复    2016-10-09 13:57:56 +08:00
    a87150
        1
    a87150  
       2016-09-27 20:09:27 +08:00
    自己写几个函数就行了吧,你是懒到什么地步
    wjidea
        2
    wjidea  
       2016-09-27 21:20:50 +08:00
    提供一个思路, 用 Python dict 来实现。

    SI = {'mm':0.001, 'cm':0.01, 'm':1.0, 'km':1000}

    def convert_SI(val, unit1, unit2):
    return val*SI[unit1]/SI[unit2]

    http://stackoverflow.com/questions/32091117/simple-unit-converter-in-python
    sherlocktheplant
        3
    sherlocktheplant  
       2016-09-27 21:56:45 +08:00
    你发帖的时间 长度转换就已经写完了
    woostundy
        4
    woostundy  
       2016-09-28 16:04:04 +08:00
    英制转公制好转,乘以系数就行。
    美元转人民币可复杂了,汇率很复杂。
    katyang
        5
    katyang  
    OP
       2016-09-30 08:54:15 +08:00
    @wjidea 谢谢
    @woostundy 就是,这样的东西居然没有现成的,难道要我 requests +selenium 动态网页获取?
    woostundy
        6
    woostundy  
       2016-10-09 13:57:56 +08:00
    @katyang 当然不会有现成的咯,汇率每天都在改变,而且不同银行不一样,而且买入和卖出价也不一样,怎么可能有免费现成的。
    路透社到时有,但得一年几十万买。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3832 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 22ms · UTC 10:28 · PVG 18:28 · LAX 03:28 · JFK 06:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.