phoenix13

导航

 

1. list 去除重复

http://python.u85.us/viewnews-6.html

 

l1 = ['b','c','d','b','c','a','a']

l2 = []

[l2.append(i) for i in l1 if not i in l2]

print l2

 

2.中文gbk字符 正则匹配

re.findall(r'<SO>[\x80-\xff]{0,10}</SO>',line)

 3. string int 互转
str(a)
int(b)
 
4. 四舍五入
http://shanchao7932297.blog.163.com/blog/static/13636242010101643316187/  

python 浮点类型 保留位数  

 >>> round(1.2)  -> 1.0
    >>> round(1.5)  -> 2.0
    >>> round(1.511,1) -- > round(1.5)

 

5.代码里有中文

# coding=gb2312

 

6. 传入系统参数

id =str(sys.argv[1]) 

 7. python调用exe

os.system('notepad.exe') 

 

posted on 2012-12-02 12:11  phoenix13  阅读(164)  评论(0编辑  收藏  举报