Not a std lib in Python, but Django has nice API as well for saving the password [0].
from django.contrib.auth.models import User
u = User.objects.get(username='john')
u.set_password('new password')
u.save()
And here is the code which does all the magic - [1]. You can also generate nice passwords [2], use many available different hashers [3] Or write your own [4][0] - https://docs.djangoproject.com/en/dev/topics/auth/default/#c...
[1] - https://github.com/django/django/blob/stable/1.10.x/django/c... and https://github.com/django/django/blob/stable/1.10.x/django/c...
[2] - https://docs.djangoproject.com/en/dev/topics/auth/customizin...
[3] - https://docs.djangoproject.com/en/dev/topics/auth/passwords/...
[4] - https://docs.djangoproject.com/en/dev/topics/auth/passwords/...