Python
nbkangta
普通在读研究生一枚
展开
-
Python的杂七杂八
1. 读取文件列表import osprint os.listdir('.')files = [f for f in os.listdir('.') if re.match("*.jpg", f) ] 2. 读取文件自动关闭with open(filename) as file: for line in file: print line...原创 2013-03-04 09:27:41 · 114 阅读 · 0 评论 -
Python字符串格式化
http://docs.python.org/2.7/library/string.html#formatspecpython内置了一个称为 Format Sepcification Mini-Language 格式化语言语言基本内容如下:format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type]f...原创 2013-03-12 17:17:03 · 106 阅读 · 0 评论 -
Python 内置格式化语言简介
Format Specified Mini-Language: 虚数的格式化 c.real, c.imag>>> c = 3 - 5j>>> ('The complex number {0} is formed from the real part {0.real} and the imaginary part {0.imag}.').f...原创 2013-05-16 09:42:38 · 265 阅读 · 0 评论 -
Python如何输出环境变量
最近项目进展顺利,编码上面没干什么事情,就学起了Python 在wxpython遇到一个问题,ubuntu 12.04下面MenuBar没办法显示查询了伟大的stackoverflow,证明是Ubuntu的一个bug,在调用脚本前设置环境变量就可以解决export UBUNTU_MENUPROXY=0 就想着集成到脚本里面去,自然的想到如下代码import os...原创 2013-02-26 13:51:23 · 1160 阅读 · 0 评论