def percent_encode(string):
    return quote(string.encode('utf-8'), '~')
A version of urllibs' quote which correctly quotes '~'
dataset/ETHPy150Open gocardless/gocardless-python/gocardless/utils.py/percent_encode