
Python
Stroot_Zhang
这个作者很懒,什么都没留下…
展开
-
Python正则表达式操作指南
原文地址:http://wiki.ubuntu.org.cn/Python%E6%AD%A3%E5%88%99%E8%A1%A8%E8%BE%BE%E5%BC%8F%E6%93%8D%E4%BD%9C%E6%8C%87%E5%8D%97摘要本文是通过Python的 re 模块来使用正则表达式的一个入门教程,和库参考手册的对应章节相比,更为浅显易懂、循序渐进。本文可以从转载 2013-07-25 11:54:50 · 730 阅读 · 0 评论 -
[Python]通过函数名字符串调用函数
可用方法整理如下:原创 2014-05-29 14:52:30 · 2005 阅读 · 0 评论 -
IPython HTML NoteBook
2011年,由Brian Granger领导的IPython团队开始开发一种基于Web技术的jiaohushi转载 2014-05-24 15:51:10 · 2173 阅读 · 0 评论 -
Python中的装饰器(decorator)
y想理解Python的decorator首先要知道在Python中函数也是一个对象,所以你可以将函数复制给变量将函数当做参数返回一个函数函数在Python中给变量的用法一样也是一等公民,也就是高阶函数(High Order Function)。所有的魔法都是由此而来。1,起源我们想在函数login中输出调试信息,我们可以这样做转载 2014-05-28 10:43:26 · 809 阅读 · 0 评论 -
PIL库编译备忘录
PIL Version:1.1.7Zlib Version: 1.2.8PIL库在编译前可通过Setup.py为其添加一些额外特性,以支持更多的功能。1.17版中支持的特性有5种,分别是zlib、tcl、jpeg、freetype、lcms。下面以为PIL添加zlib支持为例说明具体的添加步骤。1、在Setup.py中有个定义在文件首部的变量:ZLIB_原创 2014-05-27 20:03:41 · 1093 阅读 · 0 评论 -
Python 运行时捕获 Warning
参考资料:1、http://stackoverflow.com/questions/15933741/how-do-i-catch-a-warning-in-python-like-its-an-exception-not-just-for-testing原创 2014-07-20 16:37:17 · 7920 阅读 · 0 评论 -
动态创建Python类
动态创建Python可以通过使用type类来实现。type(类名, 父类的元组(针对继承的情况,可以为空),包含属性的字典(名称和值))例如:Foo = type('Foo', (object,), {'bar':True})创建了一个名为Foo的类,其父类为object类。原创 2014-03-05 14:14:00 · 797 阅读 · 0 评论 -
Python __class__
__class__用于获取当前对象的类定义。如:class class_a: count = 0 def __init__(self): pass def increase(self): self.__class__.count += 1最后一行self.__class__获取到了当前对象的类定义,然后通过self.原创 2014-03-05 13:57:43 · 2057 阅读 · 0 评论 -
查看已安装python module
进入python shell环境>>help()>modules原创 2013-10-07 17:09:49 · 1455 阅读 · 0 评论 -
Python 输出货币格式数据
>>> import locale>>> a = {'size': 123456789, 'unit': 'bytes'}>>> print(locale.format("%(size).2f", a, 1))123456789.00>>> locale.setlocale(locale.LC_ALL, '') # Set the locale for your system'原创 2013-08-14 21:01:33 · 5671 阅读 · 0 评论 -
用python输出Unicode值代表的汉字
原文地址:http://hi.baidu.com/dujun/item/4523b13af070c3bf134b14f2>>> a = "u'\u4e2d'">>> print au'\u4e2d'>>> print eval(a)中转载 2013-08-15 05:16:21 · 1583 阅读 · 0 评论 -
显示Python异常抛出所在行
实例代码:try: code;except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info(); fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print(exc_type, fname, exc_tb.tb_linen原创 2013-08-24 01:35:09 · 2826 阅读 · 1 评论 -
Python 字典结构遍历
原文地址:http://5iqiong.blog.51cto.com/2999926/806230dict={"a":"apple","b":"banana","o":"orange"} for i in dict: print "dict[%s]=" % i,dict[i] for (k,v) in dict.items(): print "di转载 2013-08-06 20:12:26 · 696 阅读 · 0 评论 -
Zinnia Installation
Important: Zinnia 0.15 only works with django 1.7 Use v0.14.3 instead.After upgrading to django 1.8 I’m recieving the error during migration:ProgrammingError: relation "django_content_type" alr原创 2015-09-19 01:17:19 · 666 阅读 · 0 评论