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.
到目前为止,我已经了解了
理解。还有其他可以“理解”的迭代吗?我最感兴趣的是 Python 3。
my_dict = {i:char for i,char in enumerate("Hello, world!")} my_list = [i**2 for i in range(10)] my_set = {i**2 for i in range(10)} my_generator = (i**2 for i in range(10))
就理解而言,我不知道更多。您当然可以在(例如)元组构造函数中使用列表/生成器理解来创建(在这种情况下)元组。但这本身不是生成器