Skip to content

Commit 693b281

Browse files
committed
Complete 0004
1 parent 5d376d1 commit 693b281

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

DIYgod/0004/count_test.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Set Up Git
2+
3+
At the heart of GitHub is an open source version control system (VCS) called Git. Git is responsible for everything GitHub-related that happens locally on your computer.

DIYgod/0004/count_word.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# -*- coding: utf-8 -*-
2+
3+
import re
4+
5+
def count(filepath):
6+
f = open(filepath, 'rb')
7+
s = f.read()
8+
words = re.findall(r'[a-zA-Z0-9]+', s)
9+
return len(words)
10+
11+
if __name__ == '__main__':
12+
num = count('count_test.txt')
13+
print num

0 commit comments

Comments
 (0)