列表排序 用 input 函数输入一个单词列表,逗号分隔,要求 ( 1 )将单词列表按单词长短降序排序,并输出; 举例如下: >>> x = ['aaaa', 'bc', 'd', 'b', 'ba'] >>> x.sort (key=len, reverse=True) # 按长度降序排序 >>>print(x) ['aaaa', 'bc', 'ba', 'd', 'b'] ( 2 )将单词列表映射为一个代表单词长度的整数列表,要求用内置函数 map 实现。 举例如下: >>> x=['a','ab','abc'] >>> print(list(map(len,x))) [1, 2, 3] 程序运行示例: