6

Replace punctuation symbols in Python

 1 year ago
source link: https://carlosvin.github.io/langs/en/posts/remove-replace-punctuation-py/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Replace punctuation symbols in Python

An example of how to remove or replace punctuation symbols of a Python string

Following I will explain how to replace punctuation symbols by whitespace.

Calling to previous function
We will get this output

We could make the function a little bit more generic to replace punctuation symbols by any other string.

Calling the function to replace punctuation symbols by "[stop]"

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK