2020年4月11日

摘要: @implementer(IAgent) class Agent(_AgentBase): def __init__(self, reactor, contextFactory=BrowserLikePolicyForHTTPS(), connectTimeout=None, bindAddress 阅读全文

posted @ 2020-04-11 20:44 王将军之武库 阅读(408) 评论(0) 推荐(0) 编辑


2018年10月12日

摘要: 包装一个iter,使其可以在迭代时出现异常时调用 错误处理函数。 并行处理函数,通过twisted的task来实现的。work是一个生成器,每次迭代时,使work前进一步。defer.DeferredList([coop.coiterate(work) for _ in range(count)]) 阅读全文

posted @ 2018-10-12 13:28 王将军之武库 阅读(386) 评论(0) 推荐(0) 编辑


2018年9月8日

摘要: model定义时,每个field都是一个类属性,一个对象。在生成类时,属性有contribute_to_class的方法,会调用该方法。 m2m field,它会先调用自己的contribute_to_class,然后调用父类的contribute_to_class,因为m2m类是继承自relatf 阅读全文

posted @ 2018-09-08 22:17 王将军之武库 阅读(328) 评论(0) 推荐(0) 编辑

摘要: """Accessors for related objects.When a field defines a relation between two models, each model class providesan attribute to access related instances 阅读全文

posted @ 2018-09-08 09:04 王将军之武库 阅读(168) 评论(0) 推荐(0) 编辑


2018年8月31日

摘要: from functools import update_wrapper def debug(func): def wrapper(): print "[DEBUG]: enter {}()".format(func.__name__) return func() return update_wrapper(wrapper,func)#使被修饰的函... 阅读全文

posted @ 2018-08-31 13:47 王将军之武库 阅读(130) 评论(0) 推荐(0) 编辑


2018年8月23日

摘要: 1.什么是xlrd模块? 2.为什么使用xlrd模块? 3.怎样使用xlrd模块? 1.什么是xlrd模块? ♦python操作excel主要用到xlrd和xlwt这两个库,即xlrd是读excel,xlwt是写excel的库。 今天就先来说一下xlrd模块: 一、安装xlrd模块 ♦ 到pytho 阅读全文

posted @ 2018-08-23 22:50 王将军之武库 阅读(339) 评论(0) 推荐(0) 编辑


2018年8月14日

摘要: class t(): pass class t2(): pass def test1(): a=10 b=t() d=t2() e=t2() def f1(c): print a print b print c f1() Disassembly of test1: 19 ... 阅读全文

posted @ 2018-08-14 13:30 王将军之武库 阅读(331) 评论(0) 推荐(0) 编辑


2018年8月13日

摘要: 闭包 e.g. def add(x): def do_add(value): return x + value return do_add add_5 = add(5) print add_5(1) # 6 print add_5(2) # 7 1 2 3 4 5 6 7 8 def add(x): 阅读全文

posted @ 2018-08-13 23:26 王将军之武库 阅读(152) 评论(0) 推荐(0) 编辑

摘要: 脚本函数编译后如何执行?脚本编译后是pyc码,pycodeobject对象的串行化。import时是对pyc文件反系列化。函数编译后会生成函数对象,函数对象的TP_call对应的是function_call。 阅读全文

posted @ 2018-08-13 23:21 王将军之武库 阅读(143) 评论(0) 推荐(0) 编辑


2018年7月16日

摘要: page_menu tag为什么能渲染出当前页的面包屑路径??靠的是request的page对象,要是page的自己或是它的的祖先才渲染,是根据page的属性page.is_current_or_ascendant,如果是才处理,不是的话就忽略。 阅读全文

posted @ 2018-07-16 22:42 王将军之武库 阅读(140) 评论(0) 推荐(0) 编辑


Copyright © 2024 王将军之武库
Powered by .NET 8.0 on Kubernetes