I have strings that I need to replace into an URL for accessing different JSON files. My problem is that some strings have special characters and I need only these as UTF-8 bytes, so I can properly find the JSON tables.
An example:
# I have this string
a = 'code - Brasilândia'
#in the JSON url it appears as
'code - Brasilândia'
I managed to get the spaces converted right using urllib.quote()
, but it does not convert the special characters as I need them.
print(urllib.quote('code - Brasilândia))
'code%20- Brasil