Python os.get_terminal_size() Method
Example
Find the size of terminal:
#Import os Library
import os
# Print the size of terminal
print (os.get_terminal_size())
Definition and Usage
The os.get_terminal_size()
return the size of a terminal as a pair of columns and lines.
Columns denotes the width of the terminal window in characters and lines denotes height of the terminal window in characters.
Syntax
os.get_terminal_size(fd = STDOUT_FILENO)
Parameter Values
Parameter | Description |
---|---|
fd | Optional. A file descriptor. The default value of file descriptor is STDOUT_FILENO or standard output. |
Technical Details
Return Value: | An object of class 'os.terminal_size' containing columns and lines attributes.
|
---|---|
Python Version: | 3.3 |