파이썬 Python 목록 항목에서 구두점 제거
다음과 같은 목록이 있습니다. ['hello', '...', 'h3.a', 'ds4,'] 이것은 ['hello', 'h3a', 'ds4'] 문자와 숫자를 그대로두고 구두점 만 제거하고 싶습니다. Punctuation is anything in the string.punctuation constant. 나는 이것이 간단 할 것이라는 것을 알고 있지만 파이썬에서는 약간의 멍청이이므로 ... 감사, Giodamelio 해결 방법 초기 목록이 변수 x에 저장되어 있다고 가정하면 다음을 사용할 수 있습니다. >>> x = [''.join(c for c in s if c not in string.punctuation) for s in x] >>> print(x) ['hello', '', 'h3a', 'ds4'] 빈..
2020. 10. 20.