First, I highly recommend you switch to Python 3, which treats Unicode strings as first-class citizens (all strings are Unicode strings, but they are called str ).
But if you need to make it work in Python 2, you can remove unicode strings with unicode.strip (if your strings are true Unicode strings):
>>> lst = [u'KATL\n', u'KCID\n'] >>> map(unicode.strip, lst) [u'KATL', u'KCID']
If your unicode strings are limited to a subset of ASCII, you can convert them to str with:
>>> lst = [u'KATL', u'KCID'] >>> map(str, lst) ['KATL', 'KCID']
Note that this conversion will not be performed for non-ASCII strings. To encode Unicode codes as str (a string of bytes), you need to select your encoding algorithm (usually UTF-8) and use the .encode() method for your strings:
>>> lst = [u'KATL', u'KCID'] >>> map(lambda x: x.encode('utf-8'), lst) ['KATL', 'KCID']
source share