base64

import base64

query = 'banner="Proxy-Agent: Privoxy" && country!="CN"'
print(query)
bytes_url = query.encode("utf-8")
base64_str = base64.b64encode(bytes_url).decode()
print(base64_str)  # YmFubmVyPSJQcm94eS1BZ2VudDogUHJpdm94eSIgJiYgY291bnRyeSE9IkNOIg==

bytes_str = base64.b64decode(base64_str)
print(bytes_str) # b'banner="Proxy-Agent: Privoxy" && country!="CN"'
str = bytes_str.decode(encoding='utf-8')
print(str) # banner="Proxy-Agent: Privoxy" && country!="CN"

更新参考