01 2016 档案

摘要:set集合set集合是一个无序并且不重复的元素集合。创建一个set集合>>> name = set('hello word')>>> name{'o', 'e', 'h', 'r', 'd', 'l', ' ', 'w'}set的方法add()作用:向set集合里面添加新的元素>>> name = ... 阅读全文
posted @ 2016-01-21 23:27 binges 阅读(243) 评论(0) 推荐(0)
摘要:collectionscollections是Python内建的一个集合模块,提供了许多有用的集合类。调用collections的方法:在程序前面添加import collections或from collections import * #$ 以下示例都使用这种方式计数器(counter)coun... 阅读全文
posted @ 2016-01-21 23:27 binges 阅读(611) 评论(0) 推荐(0)
摘要:列表(list)赋值方法:l = [11,45,67,34,89,23]l = list()列表的方法: 1 #!/usr/bin/env python 2 3 class list(object): 4 """ 5 list() -> new empty list 6 l... 阅读全文
posted @ 2016-01-13 20:49 binges 阅读(269) 评论(0) 推荐(0)
摘要:字符串:赋值方法a = 'name'a = str('name')字符串的方法: 1 #!/usr/bin/env python 2 class str(object): 3 """ 4 str(object='') -> str 5 str(bytes_or_bu... 阅读全文
posted @ 2016-01-10 17:34 binges 阅读(262) 评论(0) 推荐(0)
摘要:数字分为:整数(int)长整型(long)浮点型(float)一,整数整数(int):即不带小数点的数字,如 12 ,45 ,0 ,3#!/usr/bin/env pythonclass int(object): """ int(x=0) -> integer int(x, bas... 阅读全文
posted @ 2016-01-10 12:47 binges 阅读(257) 评论(0) 推荐(0)
摘要:变量变量的作用:变量名,代指定变量值在内存某个地址保存的内容。1,声明变量语法:变量名 = 变量值#登录号两边的空格可有可无,依据个人喜好使用例子:>>>name='youname'>>>name'youname'>>>age=28>>>age28变量的值为字符串时,必须使用引号(单引号,双引号都可... 阅读全文
posted @ 2016-01-03 09:54 binges 阅读(245) 评论(0) 推荐(0)