我想从列表中删除unicode字符串
例如 airports
[u'KATL',u'KCID']
期望输出
[KATL,KCID]
参考以下链接
Strip all the elements of a string list
尝试其中一种解决方案
my_list = ['this\n', 'is\n', 'a\n', 'list\n', 'of\n', 'words\n']
map(str.strip, my_list) ['this', 'is', 'a', 'list', 'of', 'words']
出现以下错误
TypeError: descriptor 'strip' requires a 'str' object but received a 'unicode'
u
,是吗?那你可能误解了,这不是你需要删除的东西。它只是表示你正在处理unicode
字符串而不是字节字符串。这不是你需要解决的问题。 - deceze