上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 38 下一页
摘要: 经典类只@property 没有setter 和deleter 1.23 23.4 1.23 23.4 1.23 23.4 23.4 del attr del attr del attr del attr 阅读全文
posted @ 2017-11-14 11:13 howhy 阅读(214) 评论(0) 推荐(0)
摘要: start start start this is a custom exception this is a custom exception this is a custom exception end end end myexception=MyException('231') print(ha 阅读全文
posted @ 2017-11-13 21:29 howhy 阅读(143) 评论(0) 推荐(0)
摘要: Django提供一种信号机制。其实就是观察者模式,又叫发布-订阅(Publish/Subscribe) 。当发生一些动作的时候,发出信号,然后监听了这个信号的函数就会执行。 Django内置了一些信号,比如: django.db.models.signals.pre_save 在某个Model保存之 阅读全文
posted @ 2017-11-11 13:58 howhy 阅读(942) 评论(0) 推荐(0)
摘要: class SingleObj(): __singleobj=None @classmethod def get_singleinstance(cls): if not cls.__singleobj: cls.__singleobj=SingleObj() return cls.__singleobj obj1=S... 阅读全文
posted @ 2017-11-05 16:18 howhy 阅读(156) 评论(0) 推荐(0)
摘要: PS D:\python\py_test> python3 .\t1.py 手动触发exceptionerror: 出错了 print(123) assert 1==1##若成立则执行后面的代码 反之直接报错 print(456) 阅读全文
posted @ 2017-11-05 15:23 howhy 阅读(467) 评论(0) 推荐(0)
摘要: obj=Foo()##Foo类是MyType类的对象 所以先执行MyType的init Foo()加括号执行MyType的call foo=type('Foo',(object,),{'say':lambda a:123}) ##所有类都是type类的对象 print(foo().say()) fo 阅读全文
posted @ 2017-11-05 14:40 howhy 阅读(201) 评论(0) 推荐(0)
摘要: 结果: 阅读全文
posted @ 2017-11-05 13:13 howhy 阅读(146) 评论(0) 推荐(0)
摘要: 千万不要被所谓“元类是99%的python程序员不会用到的特性”这类的说辞吓住。因为每个中国人,都是天生的元类使用者 学懂元类,你只需要知道两句话: 道生一,一生二,二生三,三生万物 我是谁?我从哪来里?我要到哪里去? 道生一,一生二,二生三,三生万物 我是谁?我从哪来里?我要到哪里去? 在pyth 阅读全文
posted @ 2017-11-05 09:45 howhy 阅读(1442) 评论(0) 推荐(0)
摘要: response.selector.xpath('//')#//从根开始匹配 .xpath('//img[@*])#找出所有img的所有属性 .xpath('//img/@src').extract()#找出所有img的src属性 .xpath('//a[@href='index.html']'). 阅读全文
posted @ 2017-10-28 21:09 howhy 阅读(155) 评论(0) 推荐(0)
摘要: 用pyenv 和 virtualenv 搭建单机多版本python 虚拟开发环境 作为主流开发语言, 用python 开发的程序越来越多。 方便的是大多linux系统里面都默认集成了python, 开发可以随时随地开始。 但有时候这也成为了一个短板, 比如说有时候我们需要开发和调试一些需要安装在默认 阅读全文
posted @ 2017-10-27 18:58 howhy 阅读(255) 评论(0) 推荐(0)
上一页 1 ··· 13 14 15 16 17 18 19 20 21 ··· 38 下一页