标签:pre ati key one lambda main 传递 __name__ ==
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)]
标签:pre ati key one lambda main 传递 __name__ ==
原文地址:https://www.cnblogs.com/SunshineKimi/p/12127145.html