How to strip comma in Python string
How can I strip the comma from a Python string such as Foo, bar ? I tried 'Foo, bar'.strip(',') , but it didn't work. You want to replace it, not strip it: s = s.replace(',', '') Use replace method of strings not strip : s = s.replace(',','') An example: >>> s = 'Foo, bar' >>> s.replace(',',' ') 'Foo bar' >>> s.replace(',','') 'Foo bar' >>> s.strip(',') # clears the ','s at the start and end of the string which there are none 'Foo, bar' >>> s.strip(',') == s True unicode('foo,bar').translate(dict([[ord(char), u''] for char in u','])) Shal This will strip all commas from the text and left