![](https://img-blog.csdnimg.cn/20201014180756754.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Python
nbkangta
普通在读研究生一枚
展开
-
Python的杂七杂八
1. 读取文件列表 import os print 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 · 116 阅读 · 0 评论 -
Python字符串格式化
http://docs.python.org/2.7/library/string.html#formatspec python内置了一个称为 Format Sepcification Mini-Language 格式化语言 语言基本内容如下: format_spec ::= [[fill]align][sign][#][0][width][,][.precision][type] f...原创 2013-03-12 17:17:03 · 107 阅读 · 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 · 267 阅读 · 0 评论 -
Python如何输出环境变量
最近项目进展顺利,编码上面没干什么事情,就学起了Python 在wxpython遇到一个问题,ubuntu 12.04下面MenuBar没办法显示 查询了伟大的stackoverflow,证明是Ubuntu的一个bug,在调用脚本前设置环境变量就可以解决 export UBUNTU_MENUPROXY=0 就想着集成到脚本里面去,自然的想到如下代码 import os ...原创 2013-02-26 13:51:23 · 1165 阅读 · 0 评论