You can probably useWindows:
os.environ.get('USERNAME') orLinux:
os.environ.get('USER') But it's not going to be safe because environment variablesBoth:
os.environ.get('USER', os.environ.get('USERNAME')) Note that environment variables can be modified by the user, so this is a potential security vulnerability. With this method, an attacker can be changedeasily fake their username.