“Hapus tanda baca dari python string” Kode Jawaban

Hapus tanda baca dari python string

#with re
import re
s = "string. With. Punctuation?"
s = re.sub(r'[^\w\s]','',s)
#without re
s = "string. With. Punctuation?"
s.translate(str.maketrans('', '', string.punctuation))
Bad Buffalo

Menghapus tanda baca di Python

import string 
from nltk.tokenize import word_tokenize
s =  set(string.punctuation)          # !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~
sentence = "Hey guys !, How are 'you' ?"
sentence = word_tokenize(sentence)
filtered_word = []
for i in sentence:
    if i not in s:
        filtered_word.append(i);
for word in filtered_word:
  print(word,end = " ")
ai-lover

tanda baca strip python3 dari string

import string
#make translator object
translator=str.maketrans('','',string.punctuation)
string_name=string_name.translate(translator)
Breakable Buffalo

tanda baca bersih dari python string

s.translate(str.maketrans('', '', string.punctuation))
Difficult Dormouse

Python Hapus tanda baca dari string

# Python program to remove punctuation from a string

import string
text= 'Hello, W_orl$d#!'

# Using translate method
print(text.translate(str.maketrans('', '', string.punctuation)))
Gorgeous Gazelle

Python menghapus tanda baca

import string 
sentence = "Hey guys !, How are 'you' ?"
no_punc_txt = ""
for char in sentence:
   if char not in string.punctuation:
       no_punc_txt = no_punc_txt + char
print(no_punc_txt);                 # Hey guys  How are you 
# or:
no_punc_txt = sentence.translate(sentence.maketrans('', '', string.punctuation))
print(no_punc_txt);                 # Hey guys  How are you 
VasteMonde

Jawaban yang mirip dengan “Hapus tanda baca dari python string”

Pertanyaan yang mirip dengan “Hapus tanda baca dari python string”

Lebih banyak jawaban terkait untuk “Hapus tanda baca dari python string” di Python

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya