Python convert pairs list to dictionary

前端 未结 4 1909
执念已碎
执念已碎 2020-12-06 09:04

I have a list of about 50 strings with an integer representing how frequently they occur in a text document. I have already formatted it like shown below, and am trying to c

4条回答
  •  悲哀的现实
    2020-12-06 10:00

    Just call dict():

    >>> string = [('limited', 1), ('all', 16), ('concept', 1), ('secondly', 1)]
    >>> dict(string)
    {'limited': 1, 'all': 16, 'concept': 1, 'secondly': 1}
    

提交回复
热议问题