The file is being read as a bunch of str
s, but it should be unicode
s. Python tries to implicitly convert, but fails. Change:
job_titles = [line.strip() for line in title_file.readlines()]
to explicitly decode the str
s to unicode
(here assuming UTF-8):
job_titles = [line.decode('utf-8').strip() for line in title_file.readlines()]
It could also be solved by importing the codecs
module and using codecs.open
rather than the built-in open
.