413
Comment:
|
424
|
Deletions are marked like this. | Additions are marked like this. |
Line 4: | Line 4: |
* an f-string is created by prefixing the string with a f e.g. ''' | * an f-string is created by prefixing the string with a f e.g. {{{ |
Line 6: | Line 6: |
''' | }}} |
Line 9: | Line 9: |
* numbers ''' a= 10.1234 >>> f'{a:.2f}' '10.12' |
* numbers {{{ a= 10.1234 >>> f'{a:.2f}' '10.12' |
Line 16: | Line 17: |
''' * date ''' ''' |
}}} * date {{{ date }}} |
Python Fstring formatting
- f - string is the latest python string formatting addition, added in 3.5
an f-string is created by prefixing the string with a f e.g.
f"this is a f-string"
Examples of f-strings
numbers
a= 10.1234 >>> f'{a:.2f}' '10.12' >>> f'{a*1000:,.2f}' '10,123.40'
date
date