码迷,mamicode.com
首页 > 编程语言 > 详细

Python学习 补充 iter partial

时间:2020-05-21 21:16:23      阅读:88      评论:0      收藏:0      [点我收藏+]

标签: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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!