Created
May 1, 2021 12:27
-
-
Save yoonseopshin/46ef269052de1a593ecf94387c1c6c35 to your computer and use it in GitHub Desktop.
파이썬 간단한 문자열 파싱: 줄 단위로 나누고 - 붙임
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
def trim(line): | |
return line.replace(" ", "") | |
def strip_html(data): | |
p = re.compile(r'<.*?>') | |
return p.sub('', data) | |
def make_bullet(line): | |
return "- " + line + "\n" | |
doc = strip_html(doc) | |
lines = doc.splitlines() | |
for line in lines: | |
str_check = set() | |
words = line.split() | |
for word in words: | |
str_check.add(word) | |
if (len(str_check) < 2): | |
continue | |
line = trim(line) | |
line = make_bullet(line) | |
print(line) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment