Skip to content

Commit 1a74b34

Browse files
committed
两点水
1 parent c7c4d7a commit 1a74b34

File tree

15 files changed

+799
-0
lines changed

15 files changed

+799
-0
lines changed

Code/Python14Code/.idea/Python14Code.iml

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Code/Python14Code/.idea/inspectionProfiles/profiles_settings.xml

Lines changed: 7 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Code/Python14Code/.idea/misc.xml

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Code/Python14Code/.idea/modules.xml

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Code/Python14Code/.idea/workspace.xml

Lines changed: 593 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Code/Python14Code/com/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: UTF-8 -*-
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: UTF-8 -*-
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: UTF-8 -*-
3+
4+
import re
5+
6+
# 设定一个常量
7+
a = '两点水|twowater|liangdianshui|草根程序员|ReadingWithU'
8+
9+
# 判断是否有 “两点水” 这个字符串,使用 PY 自带函数
10+
11+
print('a 是否含有“两点水”这个字符串:{0}'.format(a.index('两点水') > -1))
12+
print('a 是否含有“两点水”这个字符串:{0}'.format('两点水' in a))
13+
14+
# 正则表达式
15+
16+
findall = re.findall('两点水', a)
17+
print(findall)
18+
19+
if len(findall) > 0:
20+
print('a 含有“两点水”这个字符串')
21+
else:
22+
print('a 不含有“两点水”这个字符串')
23+
24+
# 选择 a 里面的所有小写英文字母
25+
26+
re_findall = re.findall('[a-z]', a)
27+
28+
print(re_findall)
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: UTF-8 -*-
3+
4+
import re
5+
6+
a = 'uav,ubv,ucv,uwv,uzv,ucv,uov'
7+
8+
# 字符集
9+
10+
# 取 u 和 v 中间是 a 或 b 或 c 的字符
11+
findall = re.findall('u[abc]v', a)
12+
print(findall)
13+
# 如果是连续的字母,数字可以使用 - 来代替
14+
l = re.findall('u[a-c]v', a)
15+
print(l)
16+
17+
# 取 u 和 v 中间不是 a 或 b 或 c 的字符
18+
re_findall = re.findall('u[^abc]v', a)
19+
print(re_findall)
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: UTF-8 -*-
3+
4+
import re
5+
6+
a = 'uav_ubv_ucv_uwv_uzv_ucv_uov&123-456-789'
7+
8+
# 概括字符集
9+
10+
# \d 相当于 [0-9] ,匹配所有数字字符
11+
# \D 相当于 [^0-9] , 匹配所有非数字字符
12+
findall1 = re.findall('\d', a)
13+
findall2 = re.findall('[0-9]', a)
14+
findall3 = re.findall('\D', a)
15+
findall4 = re.findall('[^0-9]', a)
16+
print(findall1)
17+
print(findall2)
18+
print(findall3)
19+
print(findall4)
20+
21+
# \w 匹配包括下划线的任何单词字符,等价于 [A-Za-z0-9_]
22+
findall5 = re.findall('\w', a)
23+
findall6 = re.findall('[A-Za-z0-9_]', a)
24+
print(findall5)
25+
print(findall6)

0 commit comments

Comments
 (0)