2020-10-19 21:08:55

This commit is contained in:
wizardforcel
2020-10-19 21:08:55 +08:00
parent 7f63048035
commit ab0caba1f0
140 changed files with 3982 additions and 3982 deletions

View File

@@ -2,7 +2,7 @@
In [1]:
```
```py
import collections
```
@@ -15,7 +15,7 @@ import collections
In [2]:
```
```py
from string import punctuation
sentence = "One, two, three, one, two, tree, I come from China."
@@ -26,7 +26,7 @@ print words_count
```
```
```py
Counter({'two': 2, 'one': 2, 'from': 1, 'i': 1, 'tree': 1, 'three': 1, 'china': 1, 'come': 1})
```
@@ -37,7 +37,7 @@ Counter({'two': 2, 'one': 2, 'from': 1, 'i': 1, 'tree': 1, 'three': 1, 'china':
In [3]:
```
```py
dq = collections.deque()
for i in xrange(10):
@@ -60,7 +60,7 @@ for i in xrange(10):
```
```
```py
deque([0, 1, 2, 3, 4, 5, 6, 7, 8, 9])
9 8 7 6 5 4 3 2 1 0
deque([9, 8, 7, 6, 5, 4, 3, 2, 1, 0])
@@ -72,7 +72,7 @@ deque([9, 8, 7, 6, 5, 4, 3, 2, 1, 0])
In [4]:
```
```py
lst = []
dq = collections.deque()
@@ -81,7 +81,7 @@ dq = collections.deque()
```
```
```py
100 loops, best of 3: 598 ns per loop
100 loops, best of 3: 291 ns per loop
@@ -93,7 +93,7 @@ dq = collections.deque()
In [5]:
```
```py
items = (
('A', 1),
('B', 2),
@@ -113,7 +113,7 @@ for k, v in ordered_dict.items():
```
```
```py
Regular Dict:
A 1
C 3
@@ -131,7 +131,7 @@ C 3
In [6]:
```
```py
dd = collections.defaultdict(list)
print dd["foo"]
@@ -146,7 +146,7 @@ print dd["foo"]
```
```
```py
[]
0
0.0