Browse Source

Format

pull/3/head
Jure Šorn 6 years ago
parent
commit
3c16e7cc8b
1 changed files with 4 additions and 4 deletions
  1. 8
      README.md

8
README.md

@ -273,15 +273,15 @@ import re
Format Format
------ ------
```python ```python
<str> = '{}, {}'.format(<el_1>, <el_2>)
<str> = f'{<el_1>}, {<el_2>}' <str> = f'{<el_1>}, {<el_2>}'
<str> = '{}, {}'.format(<el_1>, <el_2>)
``` ```
```python ```python
>>> person = {'name': 'Jean-Luc', 'height': 187.1}
>>> '{p[height]:.0f}'.format(p=person)
>>> person = {'name': 'Jean-Luc', 'height': 187}
>>> f"{person['height']}"
'187' '187'
>>> f"{person['height']:.0f}"
>>> '{p[height]}'.format(p=person)
'187' '187'
``` ```

Loading…
Cancel
Save