python学习十:copy模块、collections模块中的defaultdict、pydiction完成在vim中tab补全
来源:互联网 发布:sql 第几次出现 编辑:程序博客网 时间:2024/03/28 21:05
1. copy模块中的深拷贝:
3. pydiction
python中都是引用传递,所以会出现以下情况:
l1 = [1, 2]l2 = l1l2.append(3)print l1print l2# l1 = [1, 2, 3], l2 = [1, 2, 3]用[:]切片看似能解决,但是:
l1 = [[1, 2], 3]l2 = l1[:]l2.append(4)# l1 = [[1, 2], 3], l2 = [[1, 2], 3, 4]l2[0].append(5)# l1 = [[1, 2, 5], 3], l2 = [[1, 2, 5], 3, 4]copy模块中的deepcopy可以完全复制:
import copyl1 = [[1, 2], 3]l2 = copy.copy(l1) #相当于切片l3 = copy.deepcopy(l1) # 完全复制l2.append(4)l2[0].append(5)l3[0].append(6)# l1 = [[1, 2, 5], 3], l2 = [[1, 2, 5], 3, 4], l3 = [[1, 2, 6], 3]
2. collections模块中的defaultdict函数:
参数为list set int 等内建函数,用来决定值得类型。
类型为list:
import collectionss = [('yellow', 1), ('blue', 2), ('yellow', 3), ('blue', 4), ('red', 1)]d = collections.defaultdict(list)for k, v in s: d[k].append(v)list(d.items())类型为int,用来做个计数:
>>> s = 'mississippi'>>> d = defaultdict(int)>>> for k in s:... d[k] += 1...>>> d.items()[('i', 4), ('p', 2), ('s', 4), ('m', 1)]
3. pydiction
Pydiction 由 3 个主要文件构成:
python_pydiction.vim -- 该文件为 Vim 的 plugin 文件,实现 Python 文件的 TAB 补全功能。
complete-dict -- 该文件为 Vim 的 dictionary 文件,其中包含 Python 关键字和模块结构等信息。是 plugin 进行补全时所查找的参考文件。
pydiction.py -- (可选)该文件是 Python script 文件,用于生成 dictionary 文件。可以通过执行该脚本添加更多的可 TAB 补全模块。
设置可以参考# unzip pydiction-1.2.zip# cp python_pydiction.vim /usr/share/vim/vim70/ftplugin# mkdir /usr/share/vim/vim70/pydiction# cp complete-dict pydiction.py /usr/share/vim/vim70/pydiction/# vi ~/.vimrc
- python学习十:copy模块、collections模块中的defaultdict、pydiction完成在vim中tab补全
- VIM python 自动补全插件pydiction
- VIM python 自动补全插件:pydiction
- VIM python 自动补全插件:pydiction
- python中collections 模块里的defaultdict()函数
- Python的collections模块中defaultdict类型的用法
- vim 的python代码自动补全插件pydiction
- 树莓派 Python Vim使用pydiction进行代码补全
- vim 自动补全 pydiction配置
- Python中的collections模块
- Python模块: collections学习
- pydiction(vim的python语法补全插件)安装方法
- Python tab 命令补全,以及 vim 补全
- [Python模块学习]copy模块,设计模式中的原型模式
- python模块学习(collections模块)
- python学习系列---collections模块
- Python的defaultdict模块和namedtuple模块
- Python的defaultdict模块和namedtuple模块
- 浴室装修,讲舒适也讲安全
- poj 1363 Rails
- Background:rgba()
- Input 分析
- substring 的变异--jdk版本差异
- python学习十:copy模块、collections模块中的defaultdict、pydiction完成在vim中tab补全
- 全面解读WM_NOTIFY & 消息反射
- db2关于with递归使用
- win7搭建svn服务
- lock语句的递归问题
- c/c++XML读写相关
- Android -- AppWidget 初级篇
- x86 汇编语言标志寄存器
- dedecms增加php函数功能及在列表页获取当前栏目的文章数