文章分类 -  Python

Python的学习记录
摘要:1.在子类中调用父类的方法 在子类派生出的新方法中,往往需要重用父类的方法,我们有两种实现方式: 方式一:父类名.父类方法() 方式二:super().父类方法() 两种方式的区别:方式一是跟继承没有关系的,方式二是依赖于继承的,并且即使没有直接继承关系,super()仍然会按照__mro__继续往 阅读全文
posted @ 2018-03-15 20:33 土耳其大骗子 阅读(256) 评论(0) 推荐(0)
摘要:面向对象的基本知识就不多做介绍了,主要记录一下面向对象的注意事项 1.基类的构造方法 2.面向对象中self的含义,以及继承中易错的点 注意:此时调用c.xxx()函数时,函数的查找顺序如下:C -> A -> B,而B中xxx()函数,内部调用self.f1()函数,此时的self为C的实例对象, 阅读全文
posted @ 2018-03-09 17:31 土耳其大骗子 阅读(86) 评论(0) 推荐(0)
摘要:在开始介绍时间模块之前先说明几点: 一. Python中常用以下几种形式表示时间 1.时间戳 2.格式化的时间字符串 3.元组(struct_time)(共九个元素),由于Python的time模块实际是调用C库,所以各个平台可能有所不同。 二. 几个定义 UTC亦格林威治天文时间,世界标准时间。在 阅读全文
posted @ 2018-03-06 17:58 土耳其大骗子 阅读(149) 评论(0) 推荐(0)
摘要:一.迭代器 迭代器是访问集合元素的一种方式。迭代器从访问到集合的第一个元素开始访问,直到所有元素被访问结束。而且迭代器只能往前访问,不能后退。另外迭代器的另一个优点,不会事先准备好访问的集合的所有元素。迭代器只有在迭代到某个元素后才会访问元素,而在这之前或之后,元素可以不存在或者销毁,这个特点是他特 阅读全文
posted @ 2018-03-05 16:45 土耳其大骗子 阅读(203) 评论(0) 推荐(0)
摘要:简介 configparser在Python2.x中定义为ConfigParser,该模块的作用就是使用配置文件,配置文件的格式和windows中ini文件格式相同。 该模块的作用就是RawConfigParser()、ConfigParser()、SafeConfigParser()这三个方法,创 阅读全文
posted @ 2018-03-05 13:57 土耳其大骗子 阅读(109) 评论(0) 推荐(0)
摘要:有待研究 阅读全文
posted @ 2018-02-11 15:49 土耳其大骗子 阅读(61) 评论(0) 推荐(0)
摘要:sys模块常用操作如下: 1.命令行参数 sys.argv 第一个元素是程序本身路径 2.退出程序 sys.exit(n) ,正常退出程序sys.exit(0) 3.获取当前python的版本 sys.version 4.获取模块的搜索路径 sys.path ,第一个''代表当前模块的所在的目录 5 阅读全文
posted @ 2018-02-09 12:02 土耳其大骗子 阅读(137) 评论(0) 推荐(0)
摘要:官方文档 Construct an iterator from those elements of iterable for which function returns true. iterable may be either a sequence, a container which suppo 阅读全文
posted @ 2017-12-04 09:21 土耳其大骗子 阅读(868) 评论(0) 推荐(0)
摘要:Take two (non complex) numbers as arguments and return a pair of numbers consisting of their quotient and remainder when using integer division. With 阅读全文
posted @ 2017-12-03 21:58 土耳其大骗子 阅读(580) 评论(0) 推荐(0)
摘要:官方文档 Without arguments, return the list of names in the current local scope. With an argument, attempt to return a list of valid attributes for that o 阅读全文
posted @ 2017-12-03 20:03 土耳其大骗子 阅读(107) 评论(0) 推荐(0)
摘要:This is a relative of setattr(). The arguments are an object and a string. The string must be the name of one of the object’s attributes. The function 阅读全文
posted @ 2017-12-03 19:28 土耳其大骗子 阅读(109) 评论(0) 推荐(0)
摘要:官方文档 class complex([real[, imag]]) Return a complex number with the value real + imag*1j or convert a string or number to a complex number. If the fir 阅读全文
posted @ 2017-12-03 18:39 土耳其大骗子 阅读(1339) 评论(0) 推荐(0)
摘要:官方文档 Compile the source into a code or AST object. Code objects can be executed by exec() or eval(). source can either be a normal string, a byte stri 阅读全文
posted @ 2017-12-03 17:59 土耳其大骗子 阅读(223) 评论(0) 推荐(0)
摘要:官方文档: Transform a method into a class method. A class method receives the class as implicit first argument, just like an instance method receives the 阅读全文
posted @ 2017-12-03 17:27 土耳其大骗子 阅读(151) 评论(0) 推荐(0)