Python os.getlogin() Method
Example
Find the name of the user who logged in:
#Import os Library
import os
#print the name of the user logged in
print(os.getlogin())
Definition and Usage
The os.getlogin()
method returns the name of the user logged in to the terminal.
Syntax
os.getlogin()
Technical Details
Return Value: | A str value, representing the name of the logged in user |
---|---|
Python Version: | pre 2.6 |