import urllib.parse query = 'Hellö Wörld@Python' print(urllib.parse.quote(query)) >> 'Hell%C3%B6%20W%C3%B6rld%40Python'