CollectionsOverview
shfscut
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
《python必学模块-collections》第2章 tuple功能详解
name_tuple=('bobby1', 'bobby2')# tuple是iterable# 实现了魔法函数__iter__或__getitem__就是iterable的for name in name_tuple: print(name)# tuple的拆包user_tuple=('bobby', 29, 175)name, age, height=user_tupl...原创 2018-05-15 10:39:01 · 237 阅读 · 0 评论 -
《python必学模块-collections》第3章 namedtuple功能详解
class User: def __init__(self, name, age): self.name = name self.age = ageuser = User(name='bobby', age=29)print(user.name, user.age)# 对于一个对象来说,可以通过‘.’号来访问它的属性,代码字面意思非常清楚# 那么...原创 2018-05-15 15:51:33 · 283 阅读 · 0 评论 -
《python必学模块-collections》第4章 defaultdict功能详解
from collections import defaultdict#再讲解defaultdict之前,我们先了解一下传统dict完成统计功能user_dict ={}users = ['bobby1', 'bobby2', 'bobby3', 'bobby1','bobby2', 'bobby2']#统计名字出现的次数for user in users: if user n...原创 2018-05-15 15:52:40 · 297 阅读 · 0 评论
分享