|
@ -29,18 +29,18 @@ Dictionary |
|
|
---------- |
|
|
---------- |
|
|
```python |
|
|
```python |
|
|
<dict>.items() |
|
|
<dict>.items() |
|
|
<dict>.get(<key>, <default>) |
|
|
|
|
|
<dict>.setdefault(<key>, <default>) |
|
|
|
|
|
|
|
|
<dict>.get(key, default) |
|
|
|
|
|
<dict>.setdefault(key, default) |
|
|
<dict>.update(<dict>) |
|
|
<dict>.update(<dict>) |
|
|
collections.defaultdict(<type>) |
|
|
collections.defaultdict(<type>) |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
#### Initiates dict from two lists. |
|
|
|
|
|
|
|
|
#### Initiates dict from two lists |
|
|
```python |
|
|
```python |
|
|
dict(zip(keys, values)) |
|
|
dict(zip(keys, values)) |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
#### Filter by keys |
|
|
|
|
|
|
|
|
#### Filters by keys |
|
|
```python |
|
|
```python |
|
|
{k: v for k, v in <dict>.iteritems() if k in keys} |
|
|
{k: v for k, v in <dict>.iteritems() if k in keys} |
|
|
``` |
|
|
``` |
|
@ -62,7 +62,7 @@ Set |
|
|
<set>.union(<set>) |
|
|
<set>.union(<set>) |
|
|
<set>.intersection(<set>) |
|
|
<set>.intersection(<set>) |
|
|
<set>.difference(<set>) |
|
|
<set>.difference(<set>) |
|
|
<frozenset> - Is hashable and can be used as key in dictionary |
|
|
|
|
|
|
|
|
<frozenset> # Is hashable and can be used as key in dictionary |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
Range |
|
|
Range |
|
@ -122,12 +122,12 @@ str.replace(<text>, <old>, <new>) |
|
|
<str>.isnumeric() |
|
|
<str>.isnumeric() |
|
|
<str>.split() |
|
|
<str>.split() |
|
|
<str>.strip() |
|
|
<str>.strip() |
|
|
'<str>'.join(<list>) |
|
|
|
|
|
|
|
|
<str>.join(<list>) |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
### Print |
|
|
### Print |
|
|
```python |
|
|
```python |
|
|
print(<el1>, <el2>, end='', sep='', file=<file>) |
|
|
|
|
|
|
|
|
print(<el>, <el>, end='', sep='', file=<file>) |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
### Regex |
|
|
### Regex |
|
|