zoukankan      html  css  js  c++  java
  • day14作业

    with open(r'C:UsersliukaDesktop我的项目homework.text','r',encoding='utf8') as fr:
        lt1 = []
        lt2 = ['name', 'sex', 'age', 'salary']
        lt3 = []
        for i in fr:
            data=list(i.strip().split())
            print(data)
            data[3] = int(data[3])
            data[2] = int(data[2])
            dic = {k:v for k,v in zip(lt2,data)}
            lt1.append(dic)
            print(lt1)
        for i in lt1:
            num = i.get('salary')
            lt3.append(num)
    def fun(item):
        return item['salary']
    # max_num = max(lt1,key=fun)
    max_num = max(lt1,key=lambda sfjsaldjfdjsofo:sfjsaldjfdjsofo['salary'])
    print(max_num)
    min_age=min(lt1,key=lambda item:item['age'])
    print(min_age)
    
    
    
    def fun(item):
        item['name']=item['name'].capitalize()
        return item['name']
    yinshe = map(fun,lt1)
    print(list(yinshe))
    filter_start_name_a = filter(lambda item:not (item['name'].startswith('a') or item['name'].startswith('A')) ,lt1)
    print(list(filter_start_name_a))
    
    
    def sum_num(a,b,stop):
        if a >stop:
            return
        print(a)
        sum_num(b,a+b,stop)
    sum_num(0,1,10)
    
    l=[1,2,[3,[4,5,6,[7,8,[9,10,[11,12,13,[14,15]]]]]]]
    def quzhi(l):
        for i in l:
            if type(i) is list:
                quzhi(i)
            else:
                print(i)
    quzhi(l)
    
    
    
    
  • 相关阅读:
    计蒜客 动态规划基础 蒜头跳木桩
    委托的使用和合并
    asp.net "callback" 和 "postback" 的区别.
    3 顶层父类
    2 异常类
    1 智能指针
    16 #error 和 #line
    15 条件编译
    14 宏
    13 编译和链接
  • 原文地址:https://www.cnblogs.com/kaizi111/p/11588475.html
Copyright © 2011-2022 走看看