Home
Sign Up
Sign In
推荐学习书目
›
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
V2EX
›
Python
如何提高python中字典类型中的数据之间比较的效率
gavinlw
·
Nov 9, 2012
· 5201 views
This topic created in 5096 days ago, the information mentioned may be changed or developed.
有这样一个场景:
一个字典中有1000个键值对,每个值是包含200个以内词语的列表
如何快速计算出所有值(也就是说所有词语)在字典的某条记录中是否出现,以及出现次数~
也就是统计记录中包含该词的条目数。
字典
词语
键值
2 replies
•
1970-01-01 08:00:00 +08:00
1
phuslu
Nov 9, 2012
collections.defaultdict(collections.Counter)
python 2.7
2
013231
Nov 9, 2012
這種問題用reduce解決最簡單了:
http://gist.github.com/4046085
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Privacy
·
Solana
·
2507 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: d99f3d4c · 42ms ·
UTC 09:51
·
PVG 17:51
·
LAX 02:51
·
JFK 05:51
♥ Do have faith in what you're doing.
❯