next()函数、iter()函数
next()函数用于取出可迭代对象的元素,一般与iter()函数联合使用。
next(iterobject, defalt)
1.iterobject:可迭代的对象
2.default:可选当第二个参数不写入的时候,如果可迭代的元素全部取出来后,会返回Stoplteration的异常;当第二个参数写入的时候,可迭代对象完之后,会一直返回第二个参数写的数值
list = ['a', 'b', 'c'] elm = iter(list) next(elm)
原文链接:https://blog.csdn.net/silent1cat/article/details/119685424?ops_request_misc=%257B%2522request%255Fid%2522%253A%2522164767026916780261995428%2522%252C%2522scm%2522%253A%252220140713.130102334..%2522%257D&request_id=164767026916780261995428&biz_id=0&utm_medium=distribute.pc_search_result.none-task-blog-2~all~baidu_landing_v2~default-2-119685424.142^v2^pc_search_insert_es_download,143^v4^register&utm_term=python%E4%B8%ADnext%E5%87%BD%E6%95%B0%E7%9A%84%E7%94%A8%E6%B3%95&spm=1018.2226.3001.4187