• python中的三种推导式介绍

    1、列表推导式,在一个中括号里包含一个表达式。 old_list = [0,1,2,3,4,5] new_list = [] for item in old_list:     if item % 2 == 0:         new_list.append(item)   print(new_list) 2、字典推导式,把[]改成了{},并且组成元素有key和value。 old_student_score_info = {     “Jack”: {         “chinese”: …

    影音 2021年9月15日