|
@ -273,11 +273,18 @@ import re |
|
|
Format |
|
|
Format |
|
|
------ |
|
|
------ |
|
|
```python |
|
|
```python |
|
|
# Both return '<el_1>, <el_2>': |
|
|
|
|
|
<str> = '{}, {}'.format(<el_1>, <el_2>) |
|
|
<str> = '{}, {}'.format(<el_1>, <el_2>) |
|
|
<str> = f'{<el_1>}, {<el_2>}' |
|
|
<str> = f'{<el_1>}, {<el_2>}' |
|
|
``` |
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
```python |
|
|
|
|
|
>>> person = {'name': 'Jean-Luc', 'height': 187.1} |
|
|
|
|
|
>>> '{p[height]:.0f}'.format(p=person) |
|
|
|
|
|
'187' |
|
|
|
|
|
>>> f"{person['height']:.0f}" |
|
|
|
|
|
'187' |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
### General Options |
|
|
### General Options |
|
|
```python |
|
|
```python |
|
|
{<el>:<10} # '<el> ' |
|
|
{<el>:<10} # '<el> ' |
|
@ -312,15 +319,6 @@ Format |
|
|
* `'x'` - Hex |
|
|
* `'x'` - Hex |
|
|
* `'X'` - HEX |
|
|
* `'X'` - HEX |
|
|
|
|
|
|
|
|
### Example |
|
|
|
|
|
```python |
|
|
|
|
|
>>> person = {'name': 'Jean-Luc', 'height': 187.1} |
|
|
|
|
|
>>> '{p[height]:.0f}'.format(p=person) |
|
|
|
|
|
'187' |
|
|
|
|
|
>>> f"{person['height']:.0f}" |
|
|
|
|
|
'187' |
|
|
|
|
|
``` |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Numbers |
|
|
Numbers |
|
|
------- |
|
|
------- |
|
|