def test(a:str,b:int)->str:
print(test.__annotations__)
return a+str(b)

def doc_print():
"""this is test doc """
pass

def pack_args(args):
"""test 解包参数列表 """
print(list(range(*args)))

def func_lambda(m):
""" 用一个lambda表达式来返回一个函数 """
return lambda x:x+m


def sort_lambda(o):
""" 传递一个小函数作为参数:"""
o.sort(key=lambda x:x[0])
return o


if __name__ == '__main__':

a=test("a",2)
print(doc_print.__doc__)
pack_args([3,20,2])
f=func_lambda(2)
res=f(3)
print(res)
k = [("one", 11), ("three", 33), ("two", 22)]
s=sort_lambda(k)
print(s)


{'a': <class 'str'>, 'b': <class 'int'>, 'return': <class 'str'>}
this is test doc
[3, 5, 7, 9, 11, 13, 15, 17, 19]
5
[('one', 11), ('three', 33), ('two', 22)]

 

 

 




相关文章:

  • 2022-01-13
  • 2021-10-09
  • 2021-11-23
  • 2022-01-16
  • 2021-09-25
  • 2021-08-22
  • 2021-07-14
  • 2021-09-08
猜你喜欢
  • 2021-06-07
  • 2021-06-29
  • 2021-05-25
  • 2021-07-11
相关资源
相似解决方案