随笔分类 - python
摘要:1- 字典-内置数据结构,数据值与键值关联键-字典中查找部分值-字典中数据部分使用dict()工厂函数或者只用{}可以创建一个空字典>>> list = {}>>> list['name']='hello'>>> list['pwd']='world'>>> list['name']'hello'>...
阅读全文
摘要:相同功能,演进实现数据文件sarah2.txtsarah Sweeney,2002-6-17,2:58,2.58,2:39,2-25,2-55,2:54,2.18,2:55,2:551- 返回dictreturn({'Name':data_list.pop(0),'DOB':data_list.po...
阅读全文
摘要:1- "原地"排序-转换后替换>>> list = [2,1,3]>>> list.sort()>>> list[1, 2, 3]降序 reverse = True>>> list.sort(reverse = True)>>> list[3, 2, 1, 1]2- "复制"排序-转换然后返回>>>...
阅读全文
摘要:读取4个文件内容,格式化数据,升序,显示每个文件前3个数据julie.txt2.59,2.11,2:11,2:23,3-10,2-23,3:10,3.21,3-21james.txt2-34,3:21,2.34,2.45,3.01,2:01,2:01,3:10,2-22sarah.txt2:58,2...
阅读全文
摘要:datafile.txt #文件Man: this is the right room for an argument.Other Man: I've told you once.Man: No you haven'tOther Man: Yes, I have.(pause)Man: When?O...
阅读全文
摘要:1- range()1 >>> for each in range(2): print(each)2 3 ... 4 5 06 7 1
阅读全文
摘要:以2.7升级到3.3为例1.删除原版本a)删除系统库中的版本sudo rm -R /System/Library/Frameworks/Python.framework/Versions/2.7b)删除Current版本sudo rm /System/Library/Frameworks/Pytho...
阅读全文
摘要:1- 多行注释 ''' ''' 或 """ """'''this is the standard way to include a multiple-line comment in you code'''"""this is the standard way to include a multipl...
阅读全文
摘要:将模块转换为一个python发布nester.py1- 如果为函数提供一个缺省值,这个函数就是可选的,如参数level = 02- end = "" 作为print()BIF的一个参数,会关闭其默认行为(即在输入中自动包含换行)1 def print_lol(the_list, indent = F...
阅读全文
摘要:1 movies = [ "hello", "world",["xin","lover",["Jerry","cat"]]] 2 3 print movies 4 print "\n" 5 6 for each_1 in movies: 7 if isinstance(each_1,l...
阅读全文

浙公网安备 33010602011771号