I am trying to remove all the \r\n from the python dictionary. What is the easiest way to do so. My dictionary is looking like this at the moment –
{'': '34.8\r\n',
'Mozzarella di Giovanni\r\n': '34.8\r\n',
'Queso Cabrales\r\n': '14\r\n',
'Singaporean Hokkien Fried Mee\r\n': '9.8\r\n'
}
EDIT : Here’s what I’m trying –
for key, values in productDictionary.items() :
key.strip()
values.strip()
key.strip('"\"r')
key.strip('\\n')
values.strip('\\r\\n')
print productDictionary
And the output is still the same.
you can use
str.strip():str.strip()when used with no arguments, strips all types of leading and trailing whitespaces.help()onstr.strip()