Try the spwd module
Platforms: Unix
New in version 2.5.
This module provides access to the Unix shadow password database. It is available on various Unix versions.
You must have enough privileges to access the shadow password database (this usually means you have to be root).
Shadow password database entries are reported as a tuple-like object, whose attributes correspond to the members of the spwd structure (Attribute field below, see ):
>>> import spwd
>>> spwd.getspnam('root')
spwd.struct_spwd(sp_nam='root', sp_pwd='!', sp_lstchg=15238, sp_min=0, sp_max=99999, sp_warn=7, sp_inact=-1, sp_expire=-1, sp_flag=-1)
Remember, you need to have read permission of /etc/shadow
for this to work