I know that this is possible in javascript using the cardano serialization lib, as follows:
function toHex(bytes){
return Buffer.from(bytes).toString("hex");
}
function addrToPubKeyHash(bech32Addr) {
const pkh = Loader.Cardano.BaseAddress.from_address(
Loader.Cardano.Address.from_bech32(bech32Addr)
)
.payment_cred()
.to_keyhash();
return toHex(pkh.to_bytes());
}
How would I do the same in python?