I know there are some questions about this topic but I couldn't get the answer I'm looking for. So I'll ask it anyway. I'm beginner :)
I have this simple function :
f =[]
def extract_row():
with open('country_codes.txt') as infile:
for line in infile:
x = (line.split()[0])
f.append(x)
print (f)
extract_row()
It runs on python 2.7, so I could get the information I needed.
['AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AN', 'AO', 'AQ', 'AR'...
But when I try to run it on python 3.4 I get this error :
Traceback (most recent call last):
File "/Users/juanlozano/Documents/geonames/extractRow.py", line 8, in <module>
extract_row()
File "/Users/juanlozano/Documents/geonames/extractRow.py", line 4, in extract_row
for line in infile:
File "/Library/Frameworks/Python.framework/Versions/3.4/lib/python3.4/encodings/ascii.py", line 26, in decode
return codecs.ascii_decode(input, self.errors)[0]
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 31: ordinal not in range(128).
Does anyone could give some information about it?
These are some lines from the txt file I'm using : enter image description here