#/usr/bin/env python
import sys
counter = 1
while True:
line = sys.stdin.readline()
if not line:
break
print "%s:%s" % (counter,line)
counter += 1
利用管道執行
$ls|python sys.py
1:new_pysysinfo.py
2:pysysinfo.py
3:pysysinfo.pyc
4:re1.py
5:re2.py
6:sys.py
Ref: http://tianhao936.blog.51cto.com/1043670/880992
沒有留言:
張貼留言