博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
python标准库介绍——21 UserDict 模块详解
阅读量:7089 次
发布时间:2019-06-28

本文共 582 字,大约阅读时间需要 1 分钟。

==UserDict 模块==``UserDict`` 模块包含了一个可继承的字典类 (事实上是对内建字典类型的 Python 封装).[Example 2-15 #eg-2-15] 展示了一个增强的字典类, 允许对字典使用 "加/+" 操作并提供了接受关键字参数的构造函数.====Example 2-15. 使用 UserDict 模块====[eg-2-15]```File: userdict-example-1.pyimport UserDictclass FancyDict(UserDict.UserDict):    def _ _init_ _(self, data = {}, **kw):        UserDict.UserDict._ _init_ _(self)        self.update(data)        self.update(kw)    def _ _add_ _(self, other):        dict = FancyDict(self.data)        dict.update(b)        return dicta = FancyDict(a = 1)b = FancyDict(b = 2)print a + b*B*{
'b': 2, 'a': 1}*b*```

 

转载地址:http://rkfql.baihongyu.com/

你可能感兴趣的文章
网关 Spring-Cloud-Gateway 源码解析 —— 调试环境搭建
查看>>
北京时间10月11日ubuntu11.10偷偷发布
查看>>
数据库设计 Step by Step (2)——数据库生命周期
查看>>
兼容IE6下PNG24透明的几种方法
查看>>
ThinkPHP 更新数据 save方法
查看>>
HTML 元素
查看>>
Docker Mysql 安装与连接
查看>>
Nginx/Apache服务连接数梳理
查看>>
Windows下查看文件MD5值
查看>>
CentOS 6.3下Samba服务器的安装与配置
查看>>
JAVA网络编程:一站式学习Wireshark系列教程
查看>>
Spring 异步消息
查看>>
杭电2017
查看>>
ElasticSearch5.* 删除index/type 数据restful API调用
查看>>
建立共享存储实验记录
查看>>
笨方法学python VII
查看>>
【转】squid-2.6 反向代理服务器(RHEL5)
查看>>
day2作业集合
查看>>
软件开发者面试百问
查看>>
带buffer的chan能同步吗?
查看>>