Skip to content

Instantly share code, notes, and snippets.

@yoonseopshin
Created May 1, 2021 12:27
Show Gist options
  • Save yoonseopshin/46ef269052de1a593ecf94387c1c6c35 to your computer and use it in GitHub Desktop.
Save yoonseopshin/46ef269052de1a593ecf94387c1c6c35 to your computer and use it in GitHub Desktop.
파이썬 간단한 문자열 파싱: 줄 단위로 나누고 - 붙임
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