摘要: ``` #!/usr/bin/env python # -*- coding:utf-8 -*- # @Time : 2017/11/08 8:46 # @Author : lijunjiang # @File : class3.py """ 类的私有变量和私有方法 在Python中可以通过在属性变量名前加上双下划线定义属性为私有属性 特殊变量命名 1、 _xx 以单下划线开头的表示的是... 阅读全文
posted @ 2017-11-08 09:25 考鸡蛋 阅读(39184) 评论(0) 推荐(2) 编辑
摘要: ``` #!/usr/bin/env python # -*- coding:utf-8 -*- # @Time : 2017/11/7 22:46 # @Author : lijunjiang # @File : class2.py """ 类的重写 在子类中,使用与父类中相同变量或方法名,可以重新定义父类中的属性和方法 """ class A(): def hello(s... 阅读全文
posted @ 2017-11-08 09:23 考鸡蛋 阅读(5332) 评论(0) 推荐(0) 编辑
摘要: ``` #!/usr/bin/env python # -*- coding:utf-8 -*- # @Time : 2017/11/06 22:46 # @Author : lijunjiang # @File : class.py """ 类有一般形式 使用class 关键字可以创建一个类,class 后为类的名称并 ()表示的继承默认为object 并以冒号结尾,即: class... 阅读全文
posted @ 2017-11-07 00:38 考鸡蛋 阅读(299) 评论(1) 推荐(0) 编辑
摘要: ` 阅读全文
posted @ 2017-11-04 11:04 考鸡蛋 阅读(547) 评论(0) 推荐(0) 编辑
摘要: ``` #!/usr/bin/env python # -*- coding:utf-8 -*- # @Time : 2017/11/02 22:46 # @Author : lijunjiang # @File : function2.py """ 高阶函数 就是把函数当成参数传递的一种函数 """ def func1(x, y, f): return f(x) +... 阅读全文
posted @ 2017-11-02 22:57 考鸡蛋 阅读(296) 评论(0) 推荐(0) 编辑
摘要: ``` #!/usr/bin/env python # -*- coding:utf-8 -*- # @Time : 2017/11/01 21:46 # @Author : lijunjiang # @File : fanction.py """函数的一般形式""" """函数是组织好的,可重复使用的,用来实现单一,或相关联功能的代码段 可以提高应用的模块性,和代码的重复利用... 阅读全文
posted @ 2017-11-01 23:45 考鸡蛋 阅读(1323) 评论(0) 推荐(0) 编辑
摘要: 把一个数字的list从小到大排序,然后写入文件,然后从文件中读取出来文件件内容,然后反序,再追加到文件的下一行中 执行后文件内容: 分别把string list tuple dict 写入到文件中 写入的文件内容: 阅读全文
posted @ 2017-10-30 22:55 考鸡蛋 阅读(312) 评论(0) 推荐(0) 编辑
摘要: 文件操作的步骤 打开文件 对文件进行操作 关闭文件 打开文件 open("filename" [, mode]) codecs.open("filename"[, mode]) 需import codecs 模块 (处理编码转换),推荐使用 两者均返回一个 file 对象 打开方式 Mode(默认只 阅读全文
posted @ 2017-10-28 13:40 考鸡蛋 阅读(267) 评论(0) 推荐(0) 编辑
摘要: ``` #!/usr/bin/env python # -*- coding:utf-8 -*- # @Time : 2017/10/27 22:46 # @Author : lijunjiang # @File : Exercise.py """实现1-100的所有的和""" num = 0 for i in xrange(1, 101): num += i print(num... 阅读全文
posted @ 2017-10-27 01:28 考鸡蛋 阅读(337) 评论(2) 推荐(0) 编辑
摘要: break 终止整个循环:当循环或判断执行到break语句时,即使判断条件为True或者序列尚未完全被历遍,都会跳出循环或判断 continue 跳出当次循环 当循环或判断执行到continue语句时,continue后的语句将不再执行,会跳出当次循环,继续执行循环中的下一次循环 总结: conti 阅读全文
posted @ 2017-10-26 00:47 考鸡蛋 阅读(18571) 评论(0) 推荐(0) 编辑