I have a txt file, that for each line contains a last name, some last names have a special letter 'Ñ'
Apellidos200.txt
Ramos
Rios
Arias
Muñoz
To parse and read this file I use this code.
apellidos_list = list()
with io.open('Apellidos200.txt',encoding='utf-8') as fp:
for line in fp:
x = line.replace('\t','')
x = x.replace('\'', '')# I try this
x = x.replace('\n','')
x = x.replace('\r','')
x = x.replace('\\','')
x = x.replace('"','') # And try this
apellidos_list.append(repr(x))
Output:
'Ramos'
'Rios'
'Arias'
'Muñoz'
The problem is that the strings are passed with simple quotes that I cannot remove, I guess that is for the encoding in 'utf-8'
I use this string to concatenate and make an url e.g example.com/Ramos, but with this simple quotes it remains, this way -> example.com/'Ramos' and this cause an error when I use 'request.get'
Edit: Add a image with debug of code. Image of debug