how to select an object from a list of objects by its attribute in python

前端 未结 4 1161
北荒
北荒 2021-02-13 22:29

Apologies if this question has already been asked but I do not think I know the correct terminology to search for an appropriate solution through google.

I would like to

4条回答
  •  天命终不由人
    2021-02-13 23:18

    The terminology you need is 'map' or 'dictionnary' : this will lead you to the right page in the python doc.

    Extremely basic example:

    >>> a = {123:'dave', 345:'mike'}
    >>> a[123]
    'dave'
    

提交回复
热议问题