Creating a dictionary from a string

前端 未结 7 1952
轻奢々
轻奢々 2020-12-08 17:02

I have a string in the form of:

s = \'A - 13, B - 14, C - 29, M - 99\'

and so on (the length varies). What is the easiest way to create a d

相关标签:
7条回答
  • 2020-12-08 17:25
    dict((p.split(' - ') for p in s.split(',')))
    
    0 讨论(0)
提交回复
热议问题