본문 바로가기

Python56

imap 방식으로 메일의 첨부파일 다운 받기 그냥 imap 은 불편하기 때문에 imap-tools를 설치해서 이용한다 from imap_tools import MailBox #pip install imap-tools EMAIL_ADDRESS = "test@gmail.com" # 나의 메일 주소 EMAIL_PASSWORD = "asdfasdf" # 앱 비밀번호 https://support.google.com/mail/answer/185833?hl=ko mailbox = MailBox("imap.gmail.com", 993) mailbox.login(EMAIL_ADDRESS, EMAIL_PASSWORD, initial_folder="INBOX") downloads_path = "./pdf_dn/" #임의의 하위 폴더로 지정 # limit : 최대 개수.. 2022. 7. 6.
ec2 에서 파이썬 환경 셋팅 버전 정보 확인 grep . /etc/*-release 이렇게 나타난다 Amazon Linux 2 - centos rhel fedora 현재 설치된 파이썬 확인하니 2버전과 3버전 모두 있음 ls /bin | grep python 기본 파이썬 확인했더니 2버전이 기본 python -V 3버전을 기본 버전으로 하고자 함 일단 설치 가능한 최신 파이썬 확인했더니 3.8이 나옴 amazon-linux-extras | grep python 3.8 활성화 sudo amazon-linux-extras enable python3.8 3.8 설치 sudo yum install python3.8 기본 파이썬 변경 sudo update-alternatives --install /usr/bin/python python /u.. 2022. 6. 29.
탐색적 데이터 분석 (eda) 가설로 데이터 검증을 하는게 아닌 데이터를 살펴보면서 인사이트 찾기 https://pypi.org/project/sweetviz/ import pandas as pd import sweetviz as sv df = pd.read_csv("titanic.csv") my_report = sv.analyze(df) my_report.show_html() https://pypi.org/project/pandas-profiling/ import pandas as pd from pandas_profiling import ProfileReport df = pd.read_csv("titanic.csv") profile = ProfileReport(df, title="report") profile.to_file("you.. 2022. 5. 16.
오렌지3로 머신러닝 해보기 * 딥러닝과의 차이 머신러닝은 사람이 학습 데이터 제공 딥러닝은 기계가 스스로 학습 * 오렌지3 https://pypi.org/project/Orange3/ 설치 : pip install Orange3 실행 : orange-canvas * 실습 1. 공부용 데이터 추가 > 속성 예측해야 할 항목을 타겟 설정 넘버링, 날짜 등 부가 정보는 메타 설정 불필요한 정보는 스킵 나머지는 피쳐 유지 (타겟의 원인이 되는 정보) 2. 공부 데이터와 프리딕션(예측) 항목 중간에 모델로 연결 학습 진행됨 모델은 여러개 사용 가능 3. 예측용 데이터 추가 피쳐 정보는 임의로 입력해놔야 함 4. 예측 데이터와 프리딕션 연결 5. 프리딕션 더블클릭하면 결과 표시 --- 2022. 5. 16.
pywinauto 사용해보기 윈도우11의 메모장 최신 버전으로 진행 객체 구조는 inspect 도구를 구글링해서 파악해도 됨 # pip install pywinauto from pywinauto.application import Application # 메모장 실행하기 (최신 프로그램은 대체적으로 uia) app = Application(backend="uia").start("notepad.exe") # 실행 대기 # app.window(title='제목 없음 - 메모장').wait('ready', timeout=5) # 객체 구조 확인하기 # dig.print_control_identifiers() # 창 정의 (띄어쓰기 및 하이픈 없어도 인식) # dig = app['제목 없음 - 메모장'] dig = app['제목없음메모장'].. 2022. 4. 5.
[python] 이미지 자르기 #pip install pillow from PIL import Image img = Image.open(r"D:\Downloads\test.jpg") # x start, y start, x length, y length crop_area = (201,343,1491,1097) cropped_img = img.crop(crop_area) cropped_img.show() cropped_img.save('D:/Downloads/' + 'test-croped' +'.jpg', 'JPEG') 2022. 2. 11.
[python] pdf를 이미지로 변환 https://github.com/Belval/pdf2image GitHub - Belval/pdf2image: A python module that wraps the pdftoppm utility to convert PDF to PIL Image object A python module that wraps the pdftoppm utility to convert PDF to PIL Image object - GitHub - Belval/pdf2image: A python module that wraps the pdftoppm utility to convert PDF to PIL Image object github.com from pdf2image import convert_from_path # http.. 2022. 2. 11.
[python] 컨플루언스에 파일 첨부하기 https://github.com/atlassian-api/atlassian-python-api GitHub - atlassian-api/atlassian-python-api: Atlassian Python REST API wrapper Atlassian Python REST API wrapper. Contribute to atlassian-api/atlassian-python-api development by creating an account on GitHub. github.com from atlassian import Confluence confluence = Confluence( url="http://localhost:8090", username="admin", password="admin", ).. 2022. 2. 8.
파이썬 번역 - googletrans https://github.com/ssut/py-googletrans # pip install googletrans==4.0.0rc1 from googletrans import Translator tran = Translator() result = tran.translate('hello', dest='ko') print(result.text) 아직 정식 버전이 아니라 그런지 bulk 기능은 오류 발생 tran = Translator() strings = ['hello','world'] results = tran.translate(strings, dest='ko') for result in results: print(result.text) bulk 대신 for 구문으로 여러개 번역하기 tran = Tran.. 2022. 1. 20.