摘要:
使用map函数将[1,2,3,4]处理成[1,0,1,0]用以上要求作为示例:程序如下, def map_method(x): return x % 2 result_list = map(map_method, [1, 2, 3, 4]) print(list(result_list)) resu 阅读全文
posted @ 2021-01-04 14:00
cutomorrow
阅读(161)
评论(0)
推荐(0)
摘要:
实现要求: 将列表[1, 2, 3, 4, 5, 6, 7, 8, 9]按照元素与5距离从小到大进行排序 代码实现: list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9] def sorted_method(x): return abs(5-x) result = sorted(l 阅读全文
posted @ 2021-01-04 13:34
cutomorrow
阅读(539)
评论(0)
推荐(0)
浙公网安备 33010602011771号