Python 我需要知道如何对这个列表进行排序并删除这些数字
您可以使用带有str.isalpha的filter函数作为x中字符串中字符的测试条件: 这将返回:Python 我需要知道如何对这个列表进行排序并删除这些数字,python,python-3.x,Python,Python 3.x,您可以使用带有str.isalpha的filter函数作为x中字符串中字符的测试条件: 这将返回: sorted((''.join(filter(str.isalpha, s)) for s in x)) 文档排序是您的朋友: sorted((''.join(filter(str.isalpha, s)) for s in x)) ['barcelona', 'bogota', 'chennai', 'hyderabad', 'istanbul']
sorted((''.join(filter(str.isalpha, s)) for s in x))
文档排序是您的朋友:
sorted((''.join(filter(str.isalpha, s)) for s in x))
['barcelona', 'bogota', 'chennai', 'hyderabad', 'istanbul']