Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
当我想访问生成器中的元素时,我必须先做:
items = [item for item in item_generator]
然后得到我想要的items
items
尽管它很简单,但在这种操作非常频繁的情况下,键入它有点乏味。
那么是否有一个快捷方式或现有的内置函数可以解压生成器?
将生成器转换为列表怎么样?
item = list(item_generator)[2]