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
kidlfy
V2EX  ›  Python

Python 的数字字符串类型清洗有什么好方法吗?

  •  
  •   kidlfy · 2018-12-29 15:24:58 +08:00 · 1317 次点击
    这是一个创建于 1938 天前的主题,其中的信息可能已经有所发展或是发生改变。

    最近一直在处理 字符串类型的数字 比如‘ 19 万 4000 ’转为 194000 这样的整形 我只会采用笨方法转换 来问问大佬们都有什么好方法 处理字符串转数字 先谢~

    4 条回复    2018-12-29 17:11:28 +08:00
    likuku
        1
    likuku  
       2018-12-29 15:32:05 +08:00
    Google 搜 “ python 汉字转阿拉伯数字” 可有很多参考结果,下面只列出一个有 github 项目的案例:

    python 工具脚本:chinese_digit.py - 中文数字 转换为 阿拉伯数字 | Binuxの杂货铺 :
    https://binux.blog/2011/03/python-tools-chinese-digit/
    xavierskip
        2
    xavierskip  
       2018-12-29 16:19:41 +08:00
    是什么笨办法呢?
    kidlfy
        3
    kidlfy  
    OP
       2018-12-29 17:09:54 +08:00
    @xavierskip 就是分割 然后 int 转换 再加起来 这种 基本操作🤦‍♀️
    kidlfy
        4
    kidlfy  
    OP
       2018-12-29 17:11:28 +08:00
    @likuku 感谢
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   918 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 20:34 · PVG 04:34 · LAX 13:34 · JFK 16:34
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.