Archive

Portable Way To Get User ID Running Python Script

Simple way to get the user ID / username of account that is running your python script from all operating systems:

 

>>> import getpass

>>> getpass.getuser()

'testUser'

>>>