Computer Science Atlas
Snippets

Python 3: User's OS Username

February 18, 2021
 
Create animated video greeting cards and presentations with Sailboat Video Maker for iOS and macOS

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

import getpass

username = getpass.getuser()

print( username )
1
2
3
4
5
import getpass

username = getpass.getuser()

print( username )

References

Create animated video greeting cards and presentations with Sailboat Video Maker for iOS and macOS