Skip to content

Commit e7f02a3

Browse files
committed
Format
1 parent 4e42e01 commit e7f02a3

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

README.md

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -337,43 +337,43 @@ Format
337337

338338
### General Options
339339
```python
340-
{<el>:<10} # '<el> '
341-
{<el>:>10} # ' <el>'
342-
{<el>:^10} # ' <el> '
343-
{<el>:->10} # '------<el>'
344-
{<el>:>0} # '<el>'
340+
f'{<el>:<10}' # '<el> '
341+
f'{<el>:>10}' # ' <el>'
342+
f'{<el>:^10}' # ' <el> '
343+
f'{<el>:->10}' # '------<el>'
344+
f'{<el>:>0}' # '<el>'
345345
```
346346

347347
### String Options
348348
**`'!r'` calls object's repr() method, instead of format(), to get a string.**
349349
```python
350-
{'abcde'!r:<10} # "'abcde' "
351-
{'abcde':.3} # 'abc'
352-
{'abcde':10.3} # 'abc '
350+
f'{'abcde'!r:<10}' # "'abcde' "
351+
f'{'abcde':.3}' # 'abc'
352+
f'{'abcde':10.3}' # 'abc '
353353
```
354354

355355
### Number Options
356356
```python
357-
{ 123456:10,} # ' 123,456'
358-
{ 123456:10_} # ' 123_456'
359-
{ 123456:+10} # ' +123456'
360-
{-123456:=10} # '- 123456'
361-
{ 123456: } # ' 123456'
362-
{-123456: } # '-123456'
357+
f'{ 123456:10,}' # ' 123,456'
358+
f'{ 123456:10_}' # ' 123_456'
359+
f'{ 123456:+10}' # ' +123456'
360+
f'{-123456:=10}' # '- 123456'
361+
f'{ 123456: }' # ' 123456'
362+
f'{-123456: }' # '-123456'
363363
```
364364

365365
#### Float types:
366366
```python
367-
{1.23456:10.3f} # ' 1.235'
368-
{1.23456:10.3e} # ' 1.235e+00'
369-
{1.23456:10.3%} # ' 123.456%'
367+
f'{1.23456:10.3f}' # ' 1.235'
368+
f'{1.23456:10.3e}' # ' 1.235e+00'
369+
f'{1.23456:10.3%}' # ' 123.456%'
370370
```
371371

372372
#### Int types:
373373
```python
374-
{90:10c} # ' Z'
375-
{90:10X} # ' 5A'
376-
{90:010b} # '0001011010'
374+
f'{90:10c}' # ' Z'
375+
f'{90:10X}' # ' 5A'
376+
f'{90:010b}' # '0001011010'
377377
```
378378

379379

0 commit comments

Comments
 (0)