摘要:
1 #!/user/bin/env python 2 # -*- coding:utf-8 -*- 3 # 不建议继承list和dict 4 from collections import UserDict 5 from collections import defaultdict 6 7 8 class MyDict1(dict): 9 def __setitem... 阅读全文
posted @ 2019-07-26 15:24
_simpleSmile
阅读(187)
评论(0)
推荐(0)
摘要:
1 #!/user/bin/env python 2 # -*- coding:utf-8 -*- 3 import copy 4 a = {'zy': 123} 5 6 # clear 7 a.clear() 8 print(a) 9 10 # copy,返回浅拷贝 11 b = {'zy': {'school': 'hx'}} 12 new_dict = b.copy(... 阅读全文
posted @ 2019-07-26 15:12
_simpleSmile
阅读(224)
评论(0)
推荐(0)
摘要:
1 #!/user/bin/env python 2 # -*- coding:utf-8 -*- 3 # dict属于mapping类型 4 from collections.abc import Mapping, MutableMapping 5 a = {} 6 print(isinstance(a, MutableMapping)) 阅读全文
posted @ 2019-07-26 14:50
_simpleSmile
阅读(177)
评论(0)
推荐(0)
摘要:
• 列表推导式 • 生成器表达式 • 字典推导式 阅读全文
posted @ 2019-07-26 01:15
_simpleSmile
阅读(332)
评论(0)
推荐(0)
摘要:
1 #!/user/bin/env python 2 # -*- coding:utf-8 -*- 3 4 # 用来处理已排序的序列,用来维持已排序的序列,升序 5 # 二分查找 6 import bisect 7 8 9 inter_list = [] 10 bisect.insort(inter_list, 3) 11 bisect.insort(inter_list... 阅读全文
posted @ 2019-07-26 00:36
_simpleSmile
阅读(188)
评论(1)
推荐(0)
摘要:
上述是切片常用的操作,下面代码将实现一个可切片的对象 阅读全文
posted @ 2019-07-26 00:23
_simpleSmile
阅读(249)
评论(0)
推荐(0)

浙公网安备 33010602011771号