You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Every code snippet here can run independently (some need the files provided by this repo)**
15
+
-**You can use readme_snatcher.py to download README.md from the repository (Chinese or English, with or not with command line prefixes is up to you!)**
>>> re.match("www", strcmp).span() # span function to get index
146
147
(0, 3)
147
-
>>> re.match("baidu", strcmp) # re.match only match from the beginning of the string
148
-
>>> re.search("baidu", strcmp).span() # re.search search from all string and return the first
148
+
>>>
149
+
>>># re.match only match from the beginning of the string
150
+
>>> re.match("baidu", strcmp)
151
+
>>>
152
+
>>># re.search search from all string and return the first
153
+
>>> re.search("baidu", strcmp).span()
149
154
(4, 9)
150
155
>>> strcmp ="baidu.com/runoob.com"
151
-
>>> re.findall("com", strcmp) # re.findall find all results and return
156
+
>>>
157
+
>>># re.findall find all results and return
158
+
>>> re.findall("com", strcmp)
152
159
['com', 'com']
153
160
>>> re.findall("b(.*?).", strcmp)
154
161
['', '']
@@ -162,7 +169,9 @@
162
169
>>>import re
163
170
>>> re.split(r"\W", "hello,world") # use regular expression
164
171
['hello', 'world']
165
-
>>> re.sub(r"Boy|Girl", "Human", "boy and girl", flags= re.I) # re.I means ignoring apitalization
172
+
>>>
173
+
>>># re.I means ignoring capitalization
174
+
>>> re.sub(r"Boy|Girl", "Human", "boy and girl", flags= re.I)
166
175
'Human and Human'
167
176
>>> re.escape(r"#$&*+-.^|~")
168
177
'\\#\\$\\&\\*\\+\\-\\.\\^\\|\\~'
@@ -172,26 +181,6 @@
172
181
173
182
#### Differ
174
183
175
-
```python
176
-
>>>import difflib
177
-
>>> d = difflib.Differ()
178
-
>>> text1 ="""difflib
179
-
... python version 3.7.4
180
-
... difflib version 3.7.4
181
-
... this is difflib document
182
-
... """
183
-
>>> text2 ="""difflib
184
-
... python version 3.7.3
185
-
... this is difflib document
186
-
... feature: diff in linux
187
-
... """
188
-
>>> text1_lines = text1.splitlines()
189
-
>>> text2_lines = text2.splitlines()
190
-
>>>
191
-
>>>list(d.compare(text1_lines, text2_lines))
192
-
[' difflib', '- python version 3.7.4', '? ^\n', '+ python version 3.7.3', '? ^\n', '- difflib version 3.7.4', ' this is difflib document', '+ feature: diff in linux']
193
-
```
194
-
195
184
#### HtmlDiff
196
185
197
186
```python
@@ -477,17 +466,18 @@ ValueError: duplicate values found in <enum 'Unique'>: Jack -> Nick
477
466
0
478
467
>>> bisect.bisect_right(a, 1) # if it has the same, choose right
479
468
1
480
-
>>> bisect.bisect(a, 1)
469
+
>>> bisect.bisect(a, 1)# same to bisect_right
481
470
1
482
-
>>> bisect.insort(a, 1) # bisect and insert
471
+
>>> bisect.insort(a, 1) # bisect and insert (same to insort_right)
0 commit comments