python - Python3 change key type of nested dict from string to integer -
i have dict structure
players = {xxx: {'name' : "admin"}, yyy: {'name' : "user"} }
xxx , yyy meaning keys string. want them integer. how can convert keys integer please?
assuming strings xxx
, yyy
contain valid integer representations, can use following construct dict
key values converted integers:
players2 = {int(k) : v k, v in players.items()}
Comments
Post a Comment