lis1 = ['name', 'sex', 'age', 'salary']
res = []
with open('xz.txt', 'r', encoding='utf-8')as fr:
for line in fr:
line = line.strip()
lis = line.split()
dic = {k: v for k, v in zip(lis1, lis)}
res.append((dic))
res1 = res
print(res1)
res2 = max(res1, key=lambda salary: salary['salary'])
print(res2)
res3 = min(res1, key=lambda age: age['age'])
print(res3)
res4 = map(lambda name: name['name'].title(), res1)
print(list(res4))
res5 = filter(lambda info: not info['name'].startswith('a'), res1)
print(list(res5))
def f(n):
if (n <= 1):
return 1
else:
return f(n - 1) + f(n - 2)
if __name__ == "__main__":
num = int(input("n:"))
if num < 0:
print("正整数")
else:
print("".format(num))
for i in range(0, num):
print(f(i), end=" ")
l=[1,2,[3,[4,5,6,[7,8,[9,10,[11,12,13,[14,15]]]]]]]
def func1(l):
while len(l) == 0:
return
if not isinstance(l[0],list):
print(l[0])
func1(l[1:])
else:
func1(l[0])
func1(l[1:])
func1(l)