Browse Source

Main, format

pull/23/head
Jure Šorn 6 years ago
parent
commit
21dcea9bd2
1 changed files with 4 additions and 2 deletions
  1. 6
      README.md

6
README.md

@ -9,7 +9,7 @@ Comprehensive Python Cheatsheet
Main Main
---- ----
```python ```python
if __name__ == '__main__':
if __name__ == '__main__': # Runs main() if file wasn't imported.
main() main()
``` ```
@ -314,7 +314,8 @@ Format
``` ```
```python ```python
>>> Person = collections.namedtuple('Person', 'name height')
>>> from collections import namedtuple
>>> Person = namedtuple('Person', 'name height')
>>> person = Person('Jean-Luc', 187) >>> person = Person('Jean-Luc', 187)
>>> f'{person.height}' >>> f'{person.height}'
'187' '187'
@ -357,6 +358,7 @@ Format
{-123456: } # '-123456' {-123456: } # '-123456'
``` ```
#### Char, Hex, Binary:
```python ```python
{90:c} # 'Z' {90:c} # 'Z'
{90:X} # '5A' {90:X} # '5A'

Loading…
Cancel
Save