python 装饰器 decorator
2015-06-06 15:49
671 查看
# def print_word(s): # return s # if __name__ == '__main__': # print_word('helo') # hello # ------------------------------------- # but i want <ul><li>{s}</li></ul> # ------------------------------------- def make_ul(fn): print "@make_ul" def warpped(): return '<ul>'+fn()+'</ul>' return warpped def make_li(fn): print '@make_li' def warpped(): return '<li>'+fn()+'<li>' return warpped # @make_li # @make_ul def print_word2(): print 'aaa' return 'helo' if __name__ == '__main__': # print print_word2() a = make_li(print_word2) print a()
相关文章推荐
- python 正则字符串替换 re.sub 替换输入参数字符串inStrings 所有的一个或多个空格替换为newstring
- python 多线程
- python学习笔记第二课_Phoenix-晶
- python基础语法
- Python第一章基础知识
- python中simplejson模块
- Python3学习之二Django搭建
- <Python基础教程>_第五章_总结
- python str + int
- 7.python高级特性:切片,迭代,列表生成式,生成器,迭代器
- python学习之基础数据类型
- Python ConfigParser模块教程
- python处理blog文件数据
- python - re (正则表达式的学习)
- Python3.X登录模拟CSDN,获取文章列表
- 用python实现排列
- python函数内嵌,嵌套函数
- Python使用mechanize模拟浏览器
- 黄聪:Python 字符串操作(string替换、删除、截取、复制、连接、比较、查找、包含、大小写转换、分割等)
- Python标准库:内置函数tuple([iterable])