Python学习 补充 iter partial

2021-01-16 01:13

阅读:704

标签:next   pytho   for   turn   art   first   add   函数   fun   

iter:

def iter(source, sentinel=None): # known special case of iter
    """
    iter(iterable) -> iterator
    iter(callable, sentinel) -> iterator
    
    Get an iterator from an object.  In the first form, the argument must
    supply its own iterator, or be a sequence.
    In the second form, the callable is called until it returns the sentinel.
    """
    pass
l=[a,b,c,d]

def test():
    return l.pop()
y=iter(test,b)
print(y.__next__())
print(y.__next__())
# print(y.__next__())
# print(y.__next__())

partial

from functools import partial
def add(x,y):
    return x+y
# print(add(1,5))
#
func=partial(add,8) #偏函数
print(func(1))
print(func(2))

 

Python学习 补充 iter partial

标签:next   pytho   for   turn   art   first   add   函数   fun   

原文地址:https://www.cnblogs.com/sundanceS/p/12933526.html


评论


亲,登录后才可以留言!