What is the purpose of a zip function (as in Python or C# 4.0)?

后端 未结 7 2232
北荒
北荒 2020-12-29 09:27

Someone asked How to do Python’s zip in C#?...

...which leads me to ask, what good is zip? In what scenarios do I need this? Is it really so foundational that I n

7条回答
  •  情歌与酒
    2020-12-29 09:51

    A use case:

    >>> fields = ["id", "name", "location"]
    >>> values = ["13", "bill", "redmond"]
    >>> dict(zip(fields, values))
    {'location': 'redmond', 'id': '13', 'name': 'bill'}
    

    Try doing this without zip...

提交回复
热议问题