Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/348.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 我需要知道如何对这个列表进行排序并删除这些数字_Python_Python 3.x - Fatal编程技术网

Python 我需要知道如何对这个列表进行排序并删除这些数字

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']

您可以使用带有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']