Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the username in Python? [duplicate]

Tags:

python

Possible Duplicate:
Is there a portable way to get the current username in Python?

How can I get the username of the account by which the given script is being executed?

like image 360
defiant Avatar asked Dec 01 '10 14:12

defiant


People also ask

What does it mean when it says duplicate username?

A username can only be used once. When receiving 'Duplicate Username found' or 'Username already exists' error message, either pick a new username or have the User with the existing username change theirs.


1 Answers

import getpass
print getpass.getuser()
like image 174
Vladimir Lagunov Avatar answered Oct 23 '22 13:10

Vladimir Lagunov