아미(아름다운미소)

[ python] Extract sentences with specific words in a text file 본문

랭귀지/PYTHON

[ python] Extract sentences with specific words in a text file

유키공 2018. 10. 5. 09:30

python텍스트파일에서 특정 단어가 사용된 문장 추출하기

code = "찿는문자"
document_text = open('sell_list.txt', 'r', encoding='utf-8')
text_string = document_text.read()
search = code
if search in text_string:
    print("Ok")
else:
    print("NONE")
document_text.close()    
Comments