- 列表排序
-
>>> L[123, 'abc', 1.23]>>> L.sort() # 要求列表中数据类型一致才行,要么都是字符串,要么都是数字,不能数字和列表混合Traceback (most recent call last):File "<pyshell#114>", line 1, in <module>L.sort()TypeError: '<' not supported between instances of 'str' and 'int'>>> M=['a','c','f','a']>>> M.sort()>>> M['a', 'a', 'c', 'f']