上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 44 下一页
摘要: %timeit : 评估运行时间 %paste : 执行剪贴板代码 %run : 执行文件代码 %pdb : 自动调试 %pdb on 打开调试 在打开调试后,输出变量a的值 p a %pdb off 关闭调试 上下记录功能 比如说: _ 上一次输出的结果 __ 上上一次输出的结果 自动补全完整 方 阅读全文
posted @ 2021-04-17 11:29 ty1539 阅读(52) 评论(0) 推荐(0) 编辑
摘要: 参考自: https://www.cnblogs.com/chengxuyuanaa/p/12849919.html #_*_ encoding: utf-8 _*_ @author: ty hery 2020/6/4 from collections import OrderedDict # co 阅读全文
posted @ 2021-04-17 10:52 ty1539 阅读(72) 评论(0) 推荐(0) 编辑
摘要: 转自: https://www.cnblogs.com/meditator/p/7943582.html (转载:http://blog.csdn.net/passionkk/article/details/49929887) Python中 list,truple,str,dict这些都可以被迭代 阅读全文
posted @ 2021-04-16 21:18 ty1539 阅读(95) 评论(0) 推荐(0) 编辑
摘要: 在ipython2中 In [1]: from random import randint In [11]: data = [randint(-10,10) for _ in xrange(20)] # randint(-10,10) 首尾都包含 In [12]: data Out[12]: [-7 阅读全文
posted @ 2021-04-16 20:28 ty1539 阅读(15) 评论(0) 推荐(0) 编辑
摘要: 在类内部定义的函数,分为2大类: 1,绑定方法: 绑定给谁,就应该由谁调用,谁来调用就把调用者当作第一个参数自动传入 绑定到对象的方法: 在类内部定义的没有被任何装饰器修饰的,对象自动传值 绑定到类的方法: 在类内部定义的被装饰器classmethod修饰的方法 2,非绑定方法: 没有自动传值这么一 阅读全文
posted @ 2021-04-16 18:00 ty1539 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 反射:通过字符串映射到对象的属性 反射使用1 class s2: def f1(self): print('打印首页') return '首页' def f2(self): print('打印新闻') return '新闻' def f3(self): print('打印精华') return '精 阅读全文
posted @ 2021-04-16 17:24 ty1539 阅读(38) 评论(0) 推荐(0) 编辑
摘要: classonlymethodz作用:只能被类调用,不能被实例对象调用。 class A(object): bar = 1 def foo(self): print( 'foo') @staticmethod def static_foo(): print( 'static_foo') print 阅读全文
posted @ 2021-04-16 17:15 ty1539 阅读(56) 评论(0) 推荐(0) 编辑
摘要: property: 在新式类中,将类的方法变成属性,方便调用, 1,对他的get方法,添加@property装饰器, 对他的set方法和del方法要是同名函数的,添加@get方法对应的的函数名.setter, 对于python2 的经典类,只有类的get方法有效 class Student(obje 阅读全文
posted @ 2021-04-16 16:33 ty1539 阅读(107) 评论(0) 推荐(0) 编辑
摘要: ##1, 赋值 Python中,对象的赋值都是进行对象引用(内存地址)传递, 赋值(=),就是创建了对象的一个新的引用,修改其中任意一个变量都会影响到另一个 will = ["Will", 28, ["Python", "C#", "JavaScript"]] wilber = will print 阅读全文
posted @ 2021-04-16 16:23 ty1539 阅读(101) 评论(0) 推荐(0) 编辑
摘要: # sort()是列表的方法,修改原列表使得它按照大小排序,没有返回值,返回None ``` In [90]: x = [4, 6, 2, 1, 7, 9] In [91]: x.sort() In [92]: x Out[92]: [1, 2, 4, 6, 7, 9] In [98]: aa = 阅读全文
posted @ 2021-04-16 15:23 ty1539 阅读(182) 评论(0) 推荐(0) 编辑
上一页 1 ··· 31 32 33 34 35 36 37 38 39 ··· 44 下一页