Python
-
Boilerplate CopierPython/이것저것 파이썬 2023. 12. 25. 01:42
관용구를 txt파일로 관리하는 프로그램. text 폴더에 txt파일 형식으로 저장해 두면 되고, 폴더는 1단계만 지원된다.. 좌측 트리에서 파일을 선택하면 그 내용이 클립보드에 올라간다. 원하는 곳에 붙여 넣기만 하면 된다. pip install pyperclip import os import tkinter as tk from tkinter import ttk, filedialog, messagebox import pyperclip def browse_folder(): folder_path = filedialog.askdirectory() if folder_path: show_folder_structure(folder_path) def show_folder_structure(folder_path): tr..
-
다음 카페 크롤링(2023년 업데이트)Python/파이썬 웹 크롤러 2023. 11. 19. 15:58
* 지나친 크롤링은 서버에 무리를 줄 수 있으며, 계정 정지 처분을 받을 수 있습니다. 달라진 부분 1. 다음 카페의 로그인 방식 2. 셀레니움의 버전업 3. 웹 드라이버 자동 설치 설치 pip install selenium pip install webdriver-manager 코드 from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.chrome.service import Service from selenium.webdriver.common.by import By # 크롬 드라이버 자동 설치 from webdriver_manager.chrome import Chr..
-
파이썬: 콜백함수(callback)Python/이것저것 파이썬 2023. 10. 23. 07:00
함수(function)는 일등 시민(first-class citizen) 파이썬에서 함수는 일등 시민이다. https://ko.wikipedia.org/wiki/%EC%9D%BC%EA%B8%89_%EA%B0%9D%EC%B2%B4 디테일한 것은 위키의 해당항목을 참고하면 된다. 일급 객체(first-class object)란 다른 객체들에 일반적으로 적용 가능한 연산을 모두 지원하는 객체를 가리킨다. 보통 함수에 인자로 넘기기, 수정하기, 변수에 대입하기와 같은 연산을 지원할 때 일급 객체라고 한다. 여기서 함수를 다른 함수에 인자로 넘길 수 있다는 점에 주목하자. 다음과 같은 것이 가능하다. * 함수명 뒤에 '()'를 붙이면 실행되고, 전달할 때는 함수명만 사용한다는 것에 주의한다. def say_hel..
-
파이썬: 람다 표현식Python/이것저것 파이썬 2023. 10. 7. 07:12
1씩 증가하는 카운터 import tkinter counter = 0 def add(): global counter counter += 1 label.config(text=str(counter)) root = tkinter.Tk() label = tkinter.Label(root, text=str(counter)) label.pack() button = tkinter.Button(root, text='증가', width=15, command=add) button.pack() root.mainloop() 여기에 5씩 증가하는 버튼을 추가한다면? import tkinter counter = 0 def add1(): global counter counter += 1 label.config(text=str(co..
-
[python] emf 2 pngPython/이것저것 파이썬 2023. 8. 2. 10:04
PPT를 만들기 위해 PDF에 있는 사진을 천여장 옮기게 되었다. 열심히 복붙했고 --; 그런데 완성된 파일이 너무 큰 게 아닌가 ㅠ,.ㅠ pptx 파일 확장자를 zip으로 바꾼 뒤 압축을 풀면 안에 파일을 구경할 수 있다. 이미지 파일이 신기하게도 EMF라는 특이한 확장자로 되어 있더란~!! 꿀뷰에서도 지원되지 않는 특이한 포맷... (어도비의 벡터이미지 포맷인가보다.) 혹시나 파이썬의 PIL로 읽을 수 있을까 해서 돌려보니... 헉 잘 읽힌다... 이거슨~! https://www.adobe.com/kr/creativecloud/file-types/image/vector/emf-file.html EMF 파일의 정의와 여는 방법 | Adobe 벡터 이미지 포맷인 EMF(Enhanced Metafile)에..
-
[Python] 명함용 QRcode 만들기Python/이것저것 파이썬 2023. 2. 4. 19:12
[Python] QR Code for business card qrcode 라이브러리를 설치한다. pillow에 의존하기 때문에 같이 설치할 때는 다음과 같이... pip install "qrcode[pil]" 코드는 다음과 같다. 명함 용도로 쓸 수 있는 QR코드는 MECARD, vCARD 두 가지 표준이 있는 것으로 보인다. 둘 다 출력이 되도록 해 보았다. 인터넷에 흔하게 있는 QR코드 생성기는, 특정 사이트에 개인정보를 보관한 뒤 그 사이트의 링크를 남기는 방식이 많은데 신경도 쓰이고 불편하다. 이렇게 바로 QR코드에 개인정보를 저장하는 방식이 좋다. 좀 더 자세히 공부하고 싶다면 다음 주소를 참고하라. https://segno.readthedocs.io/en/latest/contact-infor..
-
[Python] WIFI QRcode 만들기Python/이것저것 파이썬 2023. 2. 4. 18:33
qrcode 라이브러리를 설치한다. pillow에 의존하기 때문에 같이 설치할 때는 다음과 같이... pip install "qrcode[pil]" 코드는 다음과 같다. import qrcode ssid = 'abcde' security = 'WPA' # WPA or WEP password = 'abcde' img = qrcode.make(f'WIFI:S:{ssid};T:{security};P:{password};;') img.save("wifi_qrcode.png") svg 파일로도 출력할 수 있다. import qrcode import qrcode.image.svg ssid = 'abcde' security = 'WPA' # WPA or WEP password = 'abcde' factory = qr..