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

怎么实现Python批量统计字数?

  •  
  •   engHacker · 2012-09-22 11:21:36 +08:00 · 5729 次点击
    这是一个创建于 4233 天前的主题,其中的信息可能已经有所发展或是发生改变。
    各位有什么思路?
    有什么库推荐吗?

    谢谢
    7 条回复    1970-01-01 08:00:00 +08:00
    twm
        1
    twm  
       2012-09-22 11:23:33 +08:00
    什么叫“批量统计字数”
    mckelvin
        2
    mckelvin  
       2012-09-22 20:01:48 +08:00
    LZ你是说统计不同word的count吗?典型的mapreduce问题呀,需要并行计算的话可以用multiprocessing或者豆瓣开源的dpark
    fanzheng
        3
    fanzheng  
       2012-09-22 21:18:23 +08:00
    reus
        4
    reus  
       2012-09-22 21:38:07 +08:00
    这不学过python的都应该会的吗?这还需要什么库啊
    dreampuf
        5
    dreampuf  
       2012-09-22 21:41:46 +08:00
    for f in os.listdir("."):
    with open(f) as fhandler:
    print fhandler.read().count("WORD")
    engHacker
        6
    engHacker  
    OP
       2012-11-20 22:06:36 +08:00
    谢谢各位,我都忘记这回事了,@fanzheng 多谢!
    yegle
        7
    yegle  
       2012-12-07 22:31:30 +08:00
    标准面试题。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3599 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 04:51 · PVG 12:51 · LAX 21:51 · JFK 00:51
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.