Computer Science Atlas
Code Review

Python 3 Examples: User's OS Username

February 18, 2021
 

The Python 3 documentation recommends using the built-in getpass.getuser() function to get the user's operating system (OS) username:

Copy
import getpass

username = getpass.getuser()

print( username )
1
2
3
4
5
import getpass

username = getpass.getuser()

print( username )

References