
Python
simple1_6的昵称用不了
这个作者很懒,什么都没留下…
展开
-
Python dict(字典)和 set
dictset原创 2017-10-10 20:09:50 · 329 阅读 · 0 评论 -
初始属性显示-- __str__
python:__str__原创 2017-10-31 16:56:17 · 273 阅读 · 0 评论 -
使用@property 改变get和set
使用@property 改变get和set方法–>属性'''使用@propety 装饰器将一个方法变成属性'''# -*- coding: utf-8 -*-class Screen(object): @property def width(self): return self._width @width.setter def width(self原创 2017-10-30 15:16:29 · 371 阅读 · 0 评论 -
动态绑定方法 MethodType()
动态绑定方法 MethodType()在动态语言中,有一种方法可以使类或者实例在没有方法或者没有想要的方法时,动态的加上一个方法。使用的就是 MethodType()其使用方法是:form types import MethodType需要绑定的类或实例.需要被绑定的方法=MethodType(方法名,类名/属性名)1.绑定方法到实例中class Student (object):原创 2017-10-30 14:58:51 · 606 阅读 · 0 评论 -
装饰器
装饰器定义:作用在代码运行期间动态的增加功能。本质上是返回函数的高阶函数。原创 2017-10-30 14:55:49 · 208 阅读 · 0 评论 -
Python debug
1.在python解释器中使用:2.在脚本中运行在需要设置断点的地方,插入方法 pdb.set_trace()原创 2017-10-11 12:28:01 · 452 阅读 · 0 评论 -
Python assert
Python assertassert是断言的意思,解释为:我断定这个程序执行之后或者之前会有这样的结果,如果不是,那就扔出一个错误。原创 2017-10-11 12:14:57 · 333 阅读 · 0 评论 -
Python 输出不换行
python 输出不换行 python 3的写法是: print(‘hello’, end=”)举个例子:>>> def clear():print('hello ',end='')print('world') >>> clear()hello world原创 2017-10-10 16:18:07 · 1131 阅读 · 0 评论 -
Python IDLE清屏
最近突然觉得Python IDLE的界面东西太多很烦,就查了一下怎么把IDLE清屏的办法,特此复制粘贴过来,以备无患。 1.下载一个名为ClearWindow.py的文件(自行百度) 2.在Python安装路径下找到Lib->idlelib->config-extensions.def(IDLE扩展的配置文件), 为防止出错,可以在打开它之前先copy一个备份 。 3.修改config-ex转载 2017-10-10 18:28:54 · 2050 阅读 · 0 评论 -
Python format 格式化函数
Python format 格式化函数函数 str.format(),增强了字符串格式化的功能。 基本语法是通过 {} 和 : 来代替以前的 % 。 format 函数可以接受不限个参数,位置可以不按顺序。转载 2017-10-10 18:55:48 · 8322 阅读 · 0 评论