day14 jobs

operation

  1. Document reads as follows, titled: name, sex, age, salary
egon male 18 3000
alex male 38 30000
wupeiqi female 28 20000
yuanhao female 28 10000

Requirements
taken into each record from the file list, each element of the list {'name':'egon','sex':'male','age':18,'salary':3000}form

  1. The list 1 obtained, the highest-paid extracted person's information
  2. According to a list obtained by removing most of the young people's information
  3. According to Table 1, it will get everyone's information in the name mapped to uppercase first letter
  4. According to a list obtained by filtering out people whose names begin with a message
  5. Print recursive Fibonacci number (numbers and the first two to give a third number, such as: 0112347 ...)
  6. A list of many layers of nested, such as l = [1,2, [3, [4,5,6, [7,8, [9,10, [11,12,13, [14,15]]] ]]]], remove all the values ​​recursively

with open("oldboy.txt","w",encoding="utf-8") as fw:
    fw.write("""
    egon male 18 3000
    alex male 38 30000
    wupeiqi female 28 20000
    yuanhao female 28 10000
    """)
with open('oldboy.txt','r',encoding='utf-8') as fr:
    lis = ['name','sex','age','salary']
    lt = []
    while True:
        try:
            res = list(fr.__next__().strip().split(' '))
            dic = {k:v for k,v in zip(lis,res)}
            # print(dic)
            lt.append(dic)
        except Exception as e:
            break
    print(lt)
res = max(lt,key = lambda k :k['salary'])
print(res)
res=min(lt,key=lambda k:k['age'] )
print(res)
res = map(lambda k:k['name'].title(),lt)
res1 = list(res)
print(res1)
res=filter(lambda dxc:not dxc['name'].startswith('a'),lt)
print(list(res))

6. Print recursive Fibonacci number (numbers and the first two to give a third number, such as: 0112347 ...)

def count(func):
    if func == 1 or func == 2:
        return 1
    else:
        return count(func-1)+count(func-2)

Guess you like

Origin www.cnblogs.com/WQ577098649/p/11588031.html