ElectrumX method blockchain.address.get_balance removed, how to get the script hash of a public addres and get balance?
Well, it's been a long time, but I've been able to find a way by myself.
The python function for getting script hash is this:
from pycoin.symbols.btc import network
import hashlib
def get_script_hash(addr):
    script = network.parse.address(addr).script()
    return hashlib.sha256(script).digest()[::-1].hex()

And the full code to check the balance of a public address from a local electrum server is:
import socket
import json
from time import sleep
from pycoin.symbols.btc import network
import hashlib

port = 50001
host = '127.0.0.1'


def get_script_hash(addr):
    script = network.parse.address(addr).script()
    return hashlib.sha256(script).digest()[::-1].hex()


def electrumx(host, port, content):
    sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    sock.connect((host, port))
    sock.sendall(json.dumps(content).encode('utf-8') + b'\n')
    sleep(0.5)
    sock.shutdown(socket.SHUT_WR)
    res = &quot;&quot;
    while True:
        data = sock.recv(1024)
        if not data:
            break
        res += data.decode()
    print(res)
    balance = eval(res)['result']
    print(f'{addr} has {balance[&quot;confirmed&quot;] / 100000000} confirmed bitcoins')
    print(f'{addr} has {balance[&quot;unconfirmed&quot;] / 100000000} unconfirmed bitcoins')
    sock.close()


if __name__ == &quot;__main__&quot;:
    addr = &quot;1x8cQ1gKJ5dwBRr1mjsYfsJbWBHJDnxg9&quot;
    script_hash = get_script_hash(addr)
    content = {
        &quot;method&quot;: &quot;blockchain.scripthash.get_balance&quot;,
        &quot;params&quot;: [script_hash],
        &quot;id&quot;: 0}
    electrumx(host, port, content)

Thank you.