- 博客(3)
- 收藏
- 关注
原创 python catch exception and continue try block
python不支持如下方式try: do_sth1() do_sth2()except: #when catch except,continue run do_sth2()但是我们可以用如下方式来实现:funcs = do_sth1, do_sth2for func in funcs: try: func() except Exception
2016-04-12 10:09:26 1129
原创 python map
function with many argsmap函数,采用偏函数方式来为函数来添加多个参数map(functools.partial(self.english_recursive, branches=branches, index=index), next_level_knowledge_tags)input a list of function!话不多说,上代码def multiply(x)
2016-04-06 20:31:17 357
转载 一行python实现树形结构
定义使用内置的defaultdict 我们可以很容易的定义一个树形数据结构def tree(): return defaultdict(tree)example:json风格users = tree()users['harold']['username'] = 'bell'users['handler']['username'] = 'master'我们可以使用print(json.dumps(
2016-04-04 13:29:35 12796
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人