- 博客(11)
- 收藏
- 关注
原创 sed的一些tricks
<br />1. remove the first line for output a file<br />cat file_name | sed '1 d'
2011-02-22 14:32:00
276
原创 python 执行命令 获取返回值 和 print内容 用module commands
<br />如果想获取执行命令的状态值,也就是$?, 可以用os.system( cmd )<br />如果想获取执行命令的print内容, 可以用os.popen( cmd ).read()<br /> <br />如果既想获取状态值,也想获取打印的内容?。。。。<br />import commands<br /> <br />stat, content = commands.getstatusoutput( cmd )<br />stat is the exit code<br />content i
2011-02-17 16:00:00
2994
2
原创 python bisect module
<br />import bisect<br /> <br />bisect is used to insert data to a sorted list<br /> <br />for example: <br />a = [ 1, 5, 8, 100 ]<br />bisect.insort( a, 9 ), then a is 1, 5, 8, 9, 100<br /> <br />bisect.bisect( a, 9 ) => 获取插入点的位置,如果插入9, 那么它的位置是多少<br />
2011-02-17 11:48:00
424
原创 Small tricks
不想让转义生效: print r'/t/r‘à /t/runicode()函数可将字符串转为unicode字符串, 要使用Unicode字符串,只要在字符串前加上“u”即可 支持中文:encoding=utf-8或gbk或gb2312# -*- coding: utf-8 -*-array.array:typecode:c => charb(B) => byte(unsigned byte)h(H) => short(unsigned short)i(I) => init( unsigned
2011-02-16 17:07:00
377
原创 fileinput: inplace
<br />if inplace is set as 1, then print will flush back the output to input file<br /> <br />def file_insert( fname, linenos = [], strings = [] ):<br /> <br />lineno = 0 # record the line no in the file <br />i = 0 # record the no. in linenos<br /> <br /
2011-02-15 15:56:00
498
原创 questions_to_michael:使用http_load一般使用什么参数?关注结果的哪一部分?
questions_to_michael: xxxxx ?tasks_to_michael: xxxxx questions_to_ada: xxxxx ?tasks_to_michael: xxxxxmessage_to_ada: xxxxx
2011-02-15 13:50:00
760
6
原创 Shell path analyze: basename or filename
在 bash 中的變量調用處理中,<br />${var#pattern} 是要將變量值左邊的最短 pattern 拿掉。<br />${var##pattern} 是要將變量值左邊的最長 pattern 拿掉。<br />因此,${var##*/} 就是將最後一個 / 及其左邊的內容拿掉。<br /><br />${var%pattern} 是要將變量值右邊的最短 pattern 拿掉。<br />${var%%pattern} 是要將變量值右邊的最長 pattern 拿掉。<br />因此,${var%
2011-02-15 12:41:00
480
原创 时间和时间戳互换
<br />当前时间戳:time.time()<br />当前日期:time.ctime()<br />1、Python下日期到时间戳的转换<br />import datetime<br />import time<br />dateC=datetime.datetime(2010,6,6,8,14,59)<br />timestamp=time.mktime(dateC.timetuple())<br />print timestamp<br />2、Python下将时间戳转换到日期<br />impo
2011-02-15 11:48:00
733
2
原创 technical articles
对CURL的一些研究: http://bbs.chinaunix.net/thread-586014-1-1.html
2011-02-15 11:16:00
558
原创 正则表达式- 捕获组 非捕获组
<br />捕获组:<br />就是把正则表达式中子表达式匹配的内容,保存到内存中以数字编号或显式命名的组里,方便后面引用。当然,这种引用既可以是在正则表达式内部,也可以是在正则表达式外部。<br /><br />temp record:<br />http://blog.sina.com.cn/s/blog_4dbe98f10100djnj.html<br />http://blogold.chinaunix.net/u/16928/showart_2504838.html<br />http://hi.
2011-02-14 18:55:00
911
2
原创 web sites
Regular-Expressions.info: http://www.regular-expressions.info/atomic.html
2011-02-14 16:48:00
476
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人