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
· 5249 views
This topic created in 5107 days ago, the information mentioned may be changed or developed.
有这样一个场景:
一个字典中有1000个键值对,每个值是包含200个以内词语的列表
如何快速计算出所有值(也就是说所有词语)在字典的某条记录中是否出现,以及出现次数~
也就是统计记录中包含该词的条目数。
字典
词语
键值
2 replies
•
1970-01-01 08:00:00 +08:00
phuslu
Nov 9, 2012
1
collections.defaultdict(collections.Counter)
python 2.7
013231
Nov 9, 2012
2
這種問題用reduce解決最簡單了:
http://gist.github.com/4046085
About
·
Help
·
Advertise
·
Blog
·
API
·
FAQ
·
Privacy
·
Solana
·
1313 Online
Highest 6679
·
Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 22ms ·
UTC 21:05
·
PVG 05:05
·
LAX 13:05
·
JFK 16:05
♥ Do have faith in what you're doing.
❯