Python convert pairs list to dictionary

前端 未结 4 1903
执念已碎
执念已碎 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 09:48

    The string variable is a list of pairs. It means you can do something somilar to this:

    string = [...]
    my_dict = {}
    for k, v in string:
      my_dict[k] = v
    

提交回复
热议问题