From f70a5a971a17912854fe798f3b26eead0ed11e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Tue, 25 Dec 2018 19:09:03 +0100 Subject: [PATCH] Format --- README.md | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3da12a7..3f1edef 100644 --- a/README.md +++ b/README.md @@ -262,8 +262,8 @@ import re ``` ### Special Sequences +**Use capital letter for negation.** ```python -# Use capital letter for negation. '\d' == '[0-9]' # Digit '\s' == '[ \t\n\r\f\v]' # Whitespace '\w' == '[a-zA-Z0-9_]' # Alphanumeric @@ -278,7 +278,7 @@ Format = f'{}, {}' ``` -#### General options: +### General Options ```python {:<10} # ' ' {:>10} # ' ' @@ -287,13 +287,13 @@ Format {:^0} # '' ``` -#### Options specific to strings: +### Options Specific to Strings: ```python {'abcde':.3} # 'abc' {'abcde':>10.3} # ' abc' ``` -#### Options specific to numbers: +### Options specific to Numbers: ```python {1.23456:.3f} # '1.235' {1.23456:>10.3f} # ' 1.235' @@ -302,15 +302,6 @@ Format {3:08b} # '00000011' -> Binary with leading zeros. ```` -#### Example: -```python ->>> person = {'name': 'Jean-Luc', 'height': 187.1} ->>> '{p[height]:.0f}'.format(p=person) -'187' ->>> f"{person['height']:.0f}" -'187' -``` - #### Float presentation types: * `'f'` - Fixed point: `.f` * `'e'` - Exponent @@ -321,6 +312,15 @@ 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 -------