python_terminalsize
Differences
This shows you the differences between two versions of the page.
python_terminalsize [2024/05/31 13:33] – created walter | python_terminalsize [2024/05/31 13:36] (current) – walter | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Terminalgröße bestimmen ====== | ====== Terminalgröße bestimmen ====== | ||
+ | <code python> | ||
+ | import shutil | ||
+ | breite, hoehe = shutil.get_terminal_size() | ||
+ | print(breite) | ||
+ | print(hoehe) | ||
+ | size = shutil.get_terminal_size() | ||
+ | print(size.columns, | ||
+ | </ | ||
- | >>> | + | Output: |
- | >>> | + | <code bash> |
- | os.terminal_size(columns=160, | + | 140 |
- | + | 35 | |
- | The output that we see is a named tuple, so we can use it in multiple ways: | + | 140, 35 |
- | + | </code> | |
- | >>> size = shutil.get_terminal_size() | + | |
- | >>> | + | |
- | 160 | + | |
- | >>> | + | |
- | >>> width | + | |
- | 160 | + | |
- | >>> | + | |
- | 9 | + |
python_terminalsize.txt · Last modified: 2024/05/31 13:36 by walter