Python | os.get_terminal_size() method
OS module in Python provides functions for interacting with the operating system. OS comes under Python’s standard utility modules. This module provides a portable way of using operating system dependent functionality.
os.get_terminal_size()
method in Python is used to query the size of a terminal. This method returns the size of a terminal as a pair columns and lines. Here, columns represents width of the terminal window in characters and lines represents height of the terminal window in characters.
Syntax: os.get_terminal_size(fd = STDOUT_FILENO)
Parameter:
fd (optional): A file descriptor. It specifies which file descriptor should be queried. The default value of fd parameter is STDOUT_FILENO or standard output.Return Type: This method returns a object of class ‘os.terminal_size’ which holds columns and lines attributes.
Code: Use of os.get_terminal_size() method
# Python program to explain os.get_terminal_size() method # importing os module import os # Get the size # of the terminal size = os.get_terminal_size() # Print the size # of the terminal print (size) |
os.terminal_size(columns=80, lines=24)
Recommended Posts:
- class method vs static method in Python
- Python | set() method
- Python | next() method
- Python | os.dup() method
- Python | numpy.ma.ids() method
- Python | os.utime() method
- Python | os.set_blocking() method
- Python | sympy.nC() method
- Python | os.getpgid() method
- Python | os.getpgrp() method
- Python | os.nice() method
- Python | os.fchdir() method
- Python | os.sched_get_priority_min() method
- Python | os.getsid() method
- Python | os.sched_rr_get_interval() method
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.