python
Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| python [2021/01/22 21:04] – created roger | python [2024/11/17 12:59] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 73: | Line 73: | ||
| ==== Convert strings to datetime ==== | ==== Convert strings to datetime ==== | ||
| + | |||
| + | More info https:// | ||
| <code python> | <code python> | ||
| Line 103: | Line 105: | ||
| print(' | print(' | ||
| >>> | >>> | ||
| + | </ | ||
| + | |||
| + | ==== Unpack extras on a tuple or list ==== | ||
| + | |||
| + | <code python> | ||
| + | t = (0, 1, 2, 3, 4) | ||
| + | |||
| + | a, b, *c = t | ||
| + | |||
| + | print(a) | ||
| + | print(b) | ||
| + | print(c) | ||
| + | # 0 | ||
| + | # 1 | ||
| + | # [2, 3, 4] | ||
| + | |||
| + | print(type(c)) | ||
| + | # <class ' | ||
| + | |||
| + | a, *b, c = t | ||
| + | |||
| + | print(a) | ||
| + | print(b) | ||
| + | print(c) | ||
| + | # 0 | ||
| + | # [1, 2, 3] | ||
| + | # 4 | ||
| + | |||
| + | *a, b, c = t | ||
| + | |||
| + | print(a) | ||
| + | print(b) | ||
| + | print(c) | ||
| + | # [0, 1, 2] | ||
| + | # 3 | ||
| + | # 4 | ||
| + | |||
| </ | </ | ||
python.1611349459.txt.gz · Last modified: 2024/11/17 12:59 (external edit)