How to get current username or User account in Python
Question:
I know there are several ways to get the current username by running below codes and I am getting my current login name however along with the Username/Login there is one more Username which I am not able to get.
e.g. When I run the following code I get the output of "KOLIK02" which is my login name.
But I want to know how do I get this "Koli, Kalpesh"
import os
import getpass
user = getpass.getuser()
user = os.getlogin()
print(user)
Answers:
have a look at this answer : https://stackoverflow.com/a/21766991/17675966
You are looking for the full Windows Name. Use win32api for such purpose.
I know there are several ways to get the current username by running below codes and I am getting my current login name however along with the Username/Login there is one more Username which I am not able to get.
e.g. When I run the following code I get the output of "KOLIK02" which is my login name.
But I want to know how do I get this "Koli, Kalpesh"
import os
import getpass
user = getpass.getuser()
user = os.getlogin()
print(user)
have a look at this answer : https://stackoverflow.com/a/21766991/17675966
You are looking for the full Windows Name. Use win32api for such purpose.