1 __author__ = 'metasequoia'
2 # -*- coding: utf-8 -*-
3 import fileinput
4
5 def Count():
6 count_num = 0
7 for line in fileinput.input('E:\Python\SpiderMyCreepy.py'):
8 num = fileinput.lineno()
9 if not line.isspace():
10 count_num +=1
11 return (num,count_num)
12
13 if __name__ == '__main__':
14 num = Count()
15 print "All_num: %s,Actual_num: %s" % (num[0],num[1]) # 全部行,没空行
#shell
wc -l /Python/Spider/MyCreepy.py #全部行
grep -v "^$" /Python/Spider/MyCreepy.py | wc -l # 没空行
wc /Python/Spider/MyCreepy.py # 行,字(包含符号),字符