0
import string
translate_table = dict((ord(char), None) for char in string.punctuation)   
tester=u'“What were the maester’s words?” Jaime asked.The bacon crunched when he bit into it.'
print sample.translate(translate_table)

-->“What were the maester’s words” Jaime askedThe bacon crunched when he bit into it

The quotation marks are still there. How to remove all the punctuation at one time?

ming
  • 427
  • 1
  • 5
  • 14
  • can you clarify a little more, are you trying to remove " or ' or both? – WildCard May 25 '16 at 18:23
  • 2
    The first thing I notice is that you are using [`string.punctuation`](https://docs.python.org/2/library/string.html#string.punctuation) as if it contained all possible punctuation in all encodings. It doesn't. It only contains *ASCII punctuation*. There are no left- and right-double quotes in ASCII. You also might want `''` instead of `None` in your `translate_table`. – Peter Rowell May 25 '16 at 18:28

0 Answers0