passmanager = urllib.request.HTTPPasswordMgrWithDefaultRealm()
passmanager.add_password(None, baseurl, username, password)
auth_handler = urllib.request.HTTPBasicAuthHandler(passmanager)
Как реализовать curl -u в Python?