Browse Source

Format

pull/3/head
Jure Šorn 5 years ago
parent
commit
fa6938d18b
1 changed files with 8 additions and 10 deletions
  1. 18
      README.md

18
README.md

@ -273,11 +273,18 @@ import re
Format
------
```python
# Both return '<el_1>, <el_2>':
<str> = '{}, {}'.format(<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
```python
{<el>:<10} # '<el> '
@ -312,15 +319,6 @@ Format
* `'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
-------

Loading…
Cancel
Save