Python
-
drawio 파일을 python 코드를 활용해 엑셀 데이터로 변환하는 방법Python 2025. 2. 14. 11:34
Drawio에서 ERD용도로 사용하던 drawio파일을 python 코드를 활용해 엑셀 데이터로 변환하는 방법import xml.etree.ElementTree as ETimport pandas as pdimport redef clean_text(text): """ 불필요한 HTML 태그 및 특정 문자열 제거 """ text = re.sub(r'', '', text) # 모든 HTML 태그 제거 text = re.sub(r'p style="[^"]*"', '', text) # 같은 스타일 태그 제거 text = re.sub(r'" in value: # 테이블 이름 감지 table_name = clean_text(value.split("")[1].split(..
-
Python Flask - URL 단축 및 QR 생성기Python 2024. 8. 2. 14:19
1. 모듈 설치pip install flask pyshorteners qrcode[pil] 2. app.py 생성from flask import Flask, render_template, request, redirect, url_forimport pyshortenersimport qrcodeimport iofrom base64 import b64encode# pip install flask pyshorteners qrcode[pil]app = Flask(__name__)@app.route('/', methods=['GET', 'POST'])def index(): if request.method == 'POST': url = request.form['url'] ..
-
Python을 이용한 엑셀 일괄 암호화 처리Python 2024. 5. 7. 17:44
# pip install pywin32import osimport win32com.client as win32# 디렉토리 경로directory = "C:\\Test\\ExcelTest"# 비밀번호password = "1234"# Excel 애플리케이션 객체 생성excel_app = win32.gencache.EnsureDispatch("Excel.Application")excel_app.Visible = False# 지정된 디렉토리에서 모든 Excel 파일 처리for filename in os.listdir(directory): if filename.endswith(('.xls', '.xlsx')): # .csv 파일은 제외 file_path = os.path.join(director..
-
Python - Plivo를 이용한 SMS 보내기Python 2021. 7. 15. 17:56
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 # pip install plivo # pip install cx_Oracle import plivo import cx_Oracle import os #환경변수 등록 LOCATION = r"C:\DH_Sel\instantclient_19_11" os.environ["PATH"] = LOCATION + ";" + os.environ["PATH"] connect = cx_Oracle.connect("DB_ID", "DB_PASSWORD", "DB_HOST:PORT/Service_Name") cursor = connect.cursor() # SQL cursor.execute("..
-
Python - Selenium SamplePython 2021. 5. 3. 09:54
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 # use chromedriver # pip install selenium import time from selenium import webdriver import datetime import os # Browser Option # options..
-
DevTools listening on ws://127.0.0.1:12740/devtools/browser/... 오류Python 2021. 3. 13. 22:03
셀레니움을 이용하다가 간혹 DevTools listening on ws://127.0.0.1:12740/devtools/browser/97101fe4-3b1f-42b0-b5c8-373cc18040b6... 와 같은 에러가 나올때가 있다. 현재 설치되있는 웹의 버전과 웹드라이버의 버전이 맞지 않아서 생기는 오류다. 웹드라이버를 최신버전으로 이용하면 해결 가능하다. ex) 크롬웹드라이버 - https://chromedriver.chromium.org/downloads
-
Windows - vscode에서 가상환경 activate 안될 때 대처Python 2020. 11. 29. 21:22
원인: Windows에서만 발생되며, Windows는 Terminal이 기본(default)으로 PowerShell로 설정되어 있기 때문이다. 해결 방법: * Terminal 기본(default)를 Command Prompt (cmd)로 변경해 주면 된다. vscode에서 Command Palette ( Ctrl + Shift + P ) 에 Terminal: Select Default Shell 입력하고 Command Prompt (cmd)로 변경한다. 변경하고 나서 Terminal을 열면 Powershell이 아닌 방금 선택한 shell로 선택되어 있으며, 자동으로 Virtualenv 가 설정된 것을 확인할 수 있다.