Browse Source

Format

pull/10/head
Jure Šorn 6 years ago
parent
commit
7af16dabe4
1 changed files with 11 additions and 11 deletions
  1. 22
      README.md

22
README.md

@ -329,32 +329,32 @@ Format
``` ```
### General Options ### General Options
```python ```bash
'{<el>:<10}' # '<el> ' {<el>:<10} # '<el> '
'{<el>:>10}' # ' <el>' {<el>:>10} # ' <el>'
'{<el>:^10}' # ' <el> ' {<el>:^10} # ' <el> '
'{<el>:->10}' # '------<el>' {<el>:->10} # '------<el>'
'{<el>:>0}' # '<el>' {<el>:>0} # '<el>'
``` ```
### String Options ### String Options
**`'!r'` calls object's repr() method, instead of format(), to get a string.** **`'!r'` calls object's repr() method, instead of format(), to get a string.**
```python ```bash
{'abcde'!r:<10} # "'abcde' " {'abcde'!r:<10} # "'abcde' "
``` ```
```python ```bash
{'abcde':.3} # 'abc' {'abcde':.3} # 'abc'
{'abcde':10.3} # 'abc ' {'abcde':10.3} # 'abc '
``` ```
### Number Options ### Number Options
```python ```bash
{1.23456:.3f} # '1.235' {1.23456:.3f} # '1.235'
{1.23456:10.3f} # ' 1.235' {1.23456:10.3f} # ' 1.235'
``` ```
```python ```bash
{ 123456:10,} # ' 123,456' { 123456:10,} # ' 123,456'
{ 123456:10_} # ' 123_456' { 123456:10_} # ' 123_456'
{ 123456:+10} # ' +123456' { 123456:+10} # ' +123456'
@ -363,7 +363,7 @@ Format
{-123456: } # '-123456' {-123456: } # '-123456'
``` ```
```python ```bash
{65:c} # 'A' {65:c} # 'A'
{3:08b} # '00000011' -> Binary with leading zeros. {3:08b} # '00000011' -> Binary with leading zeros.
{3:0<8b} # '11000000' -> Binary with trailing zeros. {3:0<8b} # '11000000' -> Binary with trailing zeros.

|||||||
100:0
Loading…
Cancel
Save