본문 바로가기

Python_Intermediate

(155)
WordCloud Basic Code>from wordcloud import WordCloud from matplotlib import pyplot text = '' with open("파일경로", encoding="utf-8") as f: text = f.read() wc = WordCloud(width=1200, height=800, scale=3.0) gen = wc.generate(text) pyplot.figure() pyplot.imshow(gen, interpolation='bilinear') wc.to_file("출력파일명") pyplot.close() 정리>4 ~ 6 : 텍스트 파일 읽어 들여 text 변수에 담아 읽어들인다. 파일경로에 자기가 만들 파일의 원본의 주소를 입력한다. 8 : WordCloud 객체 결과..
WordCloud Module Import Code>from wordcloud import WordCloud from matplotlib import pyplot 정리>import 모듈from 모듈 import 모듈함수 현재 디렉토리에 있는 파일이나 파이썬 라이브러리 모듈을 불러들여서 사용한다. wordcloud / matplotlib 는 pipinstall로 설치해서 사용이 가능하다. 워드클라우드 / 그래프 모듈을 불러들여서 사용한다.
Koera Constitution WordCloud Python Code>from wordcloud import WordCloud from matplotlib import pyplot from collections import Counter from konlpy.tag import Okt from PIL import Image import numpy text = '' with open('데이터위치', encoding="utf-8") as f: text = f.read(); nlp = Okt() nouns = nlp.nouns(text) words = [] for n in nouns: if len(n) > 1: words.append(n) count = Counter(words) most = count.most_common(100) tags = {} for..
Alice WordCloud Python Code>from wordcloud import WordCloud from matplotlib import pyplot from wordcloud import STOPWORDS from PIL import Image import numpy text = '' with open("데이터위치", encoding="utf-8") as f: text = f.read() ignore = set(STOPWORDS) ignore.add("금칙어") img = Image.open("배경화면위치"); img_array = numpy.array(img) wc = WordCloud(background_color="white", width=600, height=1200, max_font_size=150, scale..
Python 급여명세서 단체로 메일 발송 from helper import sendmail import datetime as dt now_time = dt.datetime.now() now_year = now_time.year now_month = now_time.month from_addr = "메일 발송 주소" subject_tpl = '{name}님의 {yy}년 {mm}월 급여명세서 입니다.' with open("본문 추가 사항 파일 경로", "r", encoding='utf-8') as f: content_tpl = f.read() with open("급여 명세서 파일 경로(csv파일)", "r", encoding='euc-kr') as f: csv_data = f.readlines() count = len(csv_data) result..
Gmail Python Send(Add File) 1. 선수 작업- 구글 로그인- 구글 2차 비밀번호 생성- 구글 앱 비밀번호 생성(기타 -> Python) 2. 코드import os.path from smtplib import SMTP from email.mime.text import MIMEText from email.mime.application import MIMEApplication from email.mime.multipart import MIMEMultipart content_type = "html" username = '구글메일주소' password = '구글보안비밀번호' smtp = 'smtp.gmail.com' port = 587 from_addr = "보내는 사람 주소" to_addr = "받는 사람 주소" subject = '메일제..
Python - 사용자에게 입력 받아 * 산 모양 알고리즘 Q>사용자에게 입력 받아 * 산 모양 만들기 A>star = int(input('*의 높이를 입력하세요 : ')) for i in range(star): for j in reversed(range(star)): if j > i: print(' ', end='') else: print('*', end='') for j in range(star): if j *의 높이를 입력하세요 : 5 * *** ***** **************** Process finished with exit code 0
Python - 계단식 * 출력 알고리즘 Q>계단식 * 출력 알고리즘 A>for i in range(5): for j in range(5): if j *************** Process finished with exit code 0