Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- # Filename: whoami.py
- # Version: 1.0.0
- # Author: Jeoi Reqi
- """
- Description:
- - This script retrieves the username of the current user on the system.
- Functions:
- - get_user_info(): Retrieves information about the current user on the system.
- Requirements:
- - Python 3.x
- Usage:
- - Run the script with the Python command:
- python whoami.py
- Additional Notes:
- - This script uses the getpass module to retrieve the current user's username.
- - It is compatible with Python 3.x.
- - Running the script without any arguments will print the current user's username.
- """
- import getpass
- def get_user_info():
- """
- Retrieve information about the current user on the system.
- Returns:
- dict: A dictionary containing the following user information:
- - 'Username': The current user's username.
- """
- # Get current user's username
- username = getpass.getuser()
- return {
- "Username": username
- }
- if __name__ == "__main__":
- user_info = get_user_info()
- for key, value in user_info.items():
- print(f"{key}: {value}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement