You can use the
USERNAME environment variable, which seems to be defined by default on Windows, macOS and Linux:
username = OS.get_environment("USERNAME")
username = "Player"
The snippet above falls back to
Player if the environment variable doesn't exist for some reason.
Keep in mind this may not be a good solution for multiplayer games, as many people use their real name as their computer user name and would rather stay anonymous.