摘要: (集合可以看做是字典去掉value由key组成的) 1:数据元素唯一 2:无序 3:不可变 集合的应用场景: 如果说之后做爬虫的时候,首先你是不是获取到连接,(递归),是不是同一个连接你不能重复去爬取下载 去重 ,我们就可以放到集合中 定义: s=set('xiaofan')print(s) {'i 阅读全文
posted @ 2016-09-16 15:07 xuanhui 阅读(138) 评论(0) 推荐(0)
摘要: 抛出异常: try: print("handel") #raise #抛出异常 except Exception: print('error!')else: print("no error just exec!!")finally: print("aways exec!") print("一般用来关 阅读全文
posted @ 2016-09-16 14:52 xuanhui 阅读(171) 评论(0) 推荐(0)
摘要: 定义: >>> dic={1:'a',2:'b'}>>> dic{1: 'a', 2: 'b'} >>> dic=dict(([3,"x"],[4,"y"]))>>> dic{3: 'x', 4: 'y'} 字典key是唯一的 字典是可变类型 字典是无序的类型 >>> dic={1:"a",2:"b 阅读全文
posted @ 2016-09-16 14:42 xuanhui 阅读(132) 评论(0) 推荐(0)
摘要: dir()查看属性(函数和数据对象) help()查看具体的帮助文档 id() 用来查看数据对象的地址 split 分隔(str > list): >>> s="my:name:is:xiaofan">>> s.split(":")['my', 'name', 'is', 'xiaofan'] jo 阅读全文
posted @ 2016-09-16 14:26 xuanhui 阅读(210) 评论(0) 推荐(0)