How to retreive token balance for given address using python?

Hello guys. I'm stuck here. I want to get token balance for a given eth address using web3 or whatever you want. If I search online there are just answer 4/5 years old.
The last code I tried but got error was in a post on this subreddit:
from web3 import Web3, IPCProvider
import json
token_t_abi = json.loads('[{"constant":true,"inputs":[{"name":"_owner","type":"address"}],"name":"balanceOf","outputs":[{"name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"}]')
wallet_w = '0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE'
w3 = Web3(IPCProvider())
token = w3.eth.contract(
'0x95aD61b0a150d79219dCF64E1E6Cc01f0B64C4cE',
abi=token_t_abi,
)
print(
token.call
().balanceOf(wallet_w))
Somebody can help me?
submitted by /u/gkm-chicken
[link] [comments]