delete element of string python code example
Example 1: python removing \n from string
line = line.strip('\n')
line = line.strip('\t')
Example 2: delete certain characters from a string python
for char in line:
if char in " ?.!/;:":
line.replace(char,'')
Example 3: remove from string python
"Str*ing With Chars I! don't want".replace('!','').replace('*','')
Example 4: remove a part of a string python
import re
url = 'abcdc.com'
url = re.sub('\.com$', '', url)