Home > Mobile >  how to remove double quotes from a dictionary keys?
how to remove double quotes from a dictionary keys?

Time:06-19

I have:

{'"Phone numbers"': ['0010', '55200', 'Full Names'], '"Phone numbers"': ['0015','163810', 'Full Names']

how to remove double quotes from a dictionary keys?

CodePudding user response:

Use str.replace in a dict-comprehension for example

x = {'"Phone numbers"': ['0010', '55200', 'Full Names'], '"Phone numbers"': ['0015','163810', 'Full Names']
x = {k.replace('"', ''): values for k,values in x.items()}
  • Related