Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions lulujianjie/0004/0004.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import re
lines_count = 0
#words_count = 0
chars_count = 0
lines_list = []
words_list = {}
with open('./test.txt','r') as f:
#http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/001386820066616a77f826d876b46b9ac34cb5f34374f7a000
for line in f:## ʹ���ļ������� , ÿ��ֻ��ȡ����ʾһ��
#http://blog.csdn.net/mvpme82/article/details/5674200
lines_count += 1
chars_count += len(line)#��ո�
#�������ʽhttp://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/001386832260566c26442c671fa489ebc6fe85badda25cd000
lines_list = re.findall(r'[a-zA-Z\-]+',line)
print lines_list
for i in lines_list:
#words_count += 1
if i not in words_list:
words_list[i] = 1
else:
words_list[i] += 1

print 'lines_count:',lines_count
print 'chars_count:',chars_count
print 'words_count:',len(words_list)#����ֵ��Ԫ�ظ���

for word,quantity in words_list.items():
print word,'\'s number is ',quantity
## f.close()
13 changes: 13 additions & 0 deletions lulujianjie/0004/test.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
hello world!
lujianjie
###
ksdfksdkk*&
ljj-wyj

lujianjie
###
ksdfksdkk*&
ljj-wyj lujianjie
###
ksdfksdkk*&
ljj-wyj