본문 바로가기
  • Tried. Failed. Logged.
728x90

파이썬84

Tkinter - CustomTkinter, pyinstaller 빌드 후 blue.json 에러 해결 방법 pyinstaller -F --collect-all customtkinter -w --collect-all customtkinter 옵션을 추가한다. 출처: https://stackoverflow.com/questions/75872305/how-to-get-the-correct-path-to-a-json-file-from-the-customtkinter-module How to get the correct path to a json file from the customtkinter module I made my GUI using customtkinter. I used auto-py-to-exe to make it an file. The exe file doesn't open because of an th.. 2023. 8. 13.
Tkinter - 현대적인 UI 디자인 CustomTkinter CustomTkinter 설치 명령어 pip install customtkinter​ 깃허브 주소 https://github.com/TomSchimansky/CustomTkinter GitHub - TomSchimansky/CustomTkinter: A modern and customizable python UI-library based on Tkinter A modern and customizable python UI-library based on Tkinter - GitHub - TomSchimansky/CustomTkinter: A modern and customizable python UI-library based on Tkinter github.com CustomTkinter 공식 사이트(Doc.. 2023. 8. 13.
파이썬 - 텔레그램 API 사용자 아이디 및 정보 가져오기 https://api.telegram.org/bot{bot_api_key}/getUpdates {"ok":true,"result":[{"update_id":000000000, "message":{"message_id":00,"from":{ "id":0000000000, "is_bot":false, "first_name":"ABC", "username":"ABC", "language_code":"ko"},.. 2023. 8. 1.
파이썬 - 스크립트 파일 실행 도중 인터랙티브 모드로 전환하기 import code def interactive_function(): # 스크립트 실행 중간에 인터랙티브 모드로 전환 console = code.InteractiveConsole(locals=globals()) console.interact("인터랙티브 모드로 전환합니다.") print("스크립트 실행 중...") # 스크립트 실행 로직 # 중간에 인터랙티브 모드로 전환 interactive_function() 2023. 7. 29.
셀레니움 - 특정 태그 범위 표시하기 driver.execute_script("arguments[0].style.border='2px solid red';", elem) # 태그 범위 표시 2023. 7. 29.
셀레니움 - html 서식도 포함해서 텍스트 복사하기(klembord) example.py import time import klembord from selenium import webdriver from selenium.webdriver.chrome.options import Options from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.action_chains import ActionChains options = Options() options.add_argument("--headless") options.add_argument("--disable-gpu") options.add_argument("--no-sandbox") options.add_argument("--disable.. 2023. 7. 23.
파이썬 - 로딩바(Progress Bar) 구현 모듈(tqdm) 모듈 설치 pip install tqdm 사용 예시 from time import sleep from tqdm import tqdm for i in tqdm(range(10)): sleep(1) 출처: https://stackoverflow.com/questions/3160699/python-progress-bar Python Progress Bar How do I use a progress bar when my script is doing some task that is likely to take time? For example, a function which takes some time to complete and returns True when done. How can I display a stac.. 2023. 7. 17.
파이썬 - PyAutoGUI가 안될 경우 대체 가능한 라이브러리(PyDirectInput) 기본 PyAutoGUI는 가상 키(VK)와 mouse_event() 및 keybd_event() win32 함수를 사용하고 있는데 이는 일부 응용 프로그램들, 비디오 게임이나 DirectX에 지원하지 않아 제대로 작동하지 않을 수 있다. 그래서 PyDirectInput 라이브러리는 DirectInput 스캔 코드와 SendInput() win32 같은 최신 방식을 사용해 이 문제를 해결할 수 있다. PyPi - PyDirectInput https://pypi.org/project/PyDirectInput/ PyDirectInput Python mouse and keyboard input automation for Windows using Direct Input. pypi.org 코드 예제 >>> impo.. 2023. 7. 15.
셀레니움 - xpath 자바스크립트로 클릭하기 (javascript error: $x is not defined) 방법 1. marketplace_button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//span[contains(text(), "Marketplace")]'))) marketplace_button.click() 방법 2. marketplace_button = WebDriverWait(driver, 20).until(EC.element_to_be_clickable((By.XPATH, '//span[contains(text(), "Marketplace")]'))) driver.execute_script("arguments[0].click();", marketplace_button) 출처: https://stackove.. 2023. 6. 11.
파이썬 - 리눅스에서 GPT 명령어 사용하기 모듈 설치 pip install openai ~/dev/gpt.py import openai import sys openai.api_key = "자신의 API 토큰을 여기에 입력" messages = [ {"role": "system", "content": "You are a helpful assistant."}, ] def request(text:str): global messages if len(messages) >= 30: messages = messages[-10:] query = text messages.append({"role": "user", "content": query}) response = openai.ChatCompletion.create( model="gpt-3.5-turbo", m.. 2023. 5. 22.
셀레니움 - xpath, 텍스트가 포함된 요소 선택(contains text) 원하는 문자열인 요소 찾기 ex) 요소의 내용이 foo인 것을 찾기 //myparent/mychild[text() = 'foo'] 원하는 문자열이 포함한(contains) 요소 찾기 ex) ABC라는 내용을 포함한 있는 요소 찾기 //*[contains(text(),'ABC')] 파이썬 사용 예시 driver.find_element_by_xpath('//span[contains(text(),"ABC")]') 자바스크립트(브라우저 개발자 도구) 사용 예시 $x("//*[contains(text(),'12:00')]") 그 문자인 것을 찾기 $x('//*[text()="네이버로 이용하기"]') 속성(class나 id) 값이 특정 문자로 시작하는 요소 찾기 $x("//div[starts-with(@class,.. 2023. 5. 7.
파이썬 - 레지스트리 조작(winreg) import winreg # 레지스트리 키 생성 key_path = r"Software\MyExampleKey" try: key = winreg.CreateKey(winreg.HKEY_CURRENT_USER, key_path) print("키 생성 성공") except: print("키 생성 실패") # 레지스트리 키에 값 설정 value_name = "ExampleValue" value_data = "Hello, Registry!" try: winreg.SetValueEx(key, value_name, 0, winreg.REG_SZ, value_data) winreg.CloseKey(key) print("값 설정 성공") except: print("값 설정 실패") # 레지스트리 키에서 값 읽기 try.. 2023. 5. 5.
728x90