I need to check if a user exists in either Linux or Windows, using Python 3 (3.7 right now for reasons unrelated).
No, pwd
doesn't work on Windows.
No, getpass
only returns current username, while I need to check any username.
I need to check if a user exists in either Linux or Windows, using Python 3 (3.7 right now for reasons unrelated).
No, pwd
doesn't work on Windows.
No, getpass
only returns current username, while I need to check any username.
as far as i know, there is no universal command for both distros, but you can check the env in your script
import os
if os.name [...]
or
import platform
my_os = platform.system()
based on this you can create different functions for both os.