필요없는 문자열 제거 파이썬 치트코드

Untitled4
In [5]:
def clean_special_chars(text, punct):
    for p in punct:
        text = text.replace(p, ' ')
    return text
In [8]:
text = "Hi, Welcome to machinelearning korea (very good), ^.^"
punct = "/-'?!.,#$%\'()*+-/:;<=>@[\\]^_`{|}~`" + '""“”’' + '∞θ÷α•à−β∅³π‘₹´°£€\×™√²—–&'
In [9]:
clean_special_chars(text, punct)
Out[9]:
'Hi  Welcome to machinelearning korea  very good      '

답글 남기기