We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 911eaa5 commit d2cdf28Copy full SHA for d2cdf28
1 file changed
Liez-python-code/0004/0004.py
@@ -0,0 +1,20 @@
1
+# coding = utf-8
2
+__author__= 'liez'
3
+
4
+import re
5
+def num(path):
6
+ with open(path, 'r') as file:
7
+ data=file.read()
8
+ print(data)
9
+ words=re.compile('[a-zA-Z0-9]+') #compile好像是必须用的,用来格式转换什么的,然后才能进行匹配之类的操作
10
+ dict={}
11
12
+ for x in words.findall(data):
13
+ if x not in dict:
14
+ dict[x]=1
15
+ else:
16
+ dict[x]+=1
17
18
+ print(dict)
19
20
+num('liez.txt')
0 commit comments