Python Program to Get Current Username of Computer

This Python program prints current username of your computer using getpass library.

Python Source Code


import getpass
print("Current username is: ", getpass.getuser())

Output

Current username is: codesansar