Pytesseract로 한국어+영어 인식하기
·
코딩/Python
1. Tesseract OCR 설치https://github.com/UB-Mannheim/tesseract/wiki HomeTesseract Open Source OCR Engine (main repository) - UB-Mannheim/tesseractgithub.com위 링크로 접속하여 빨간색으로 표시된 파일을 다운로드하고 실행하여 Tesseract OCR을 설치합니다.    2. 한국어 인식을 위한 훈련 데이터 받기https://github.com/tesseract-ocr/tessdata/raw/main/kor.traineddata tessdata/kor.traineddata at main · tesseract-ocr/tessdataTrained models with fast variant of ..
[Python] 실행중인 프로세스 확인하기
·
코딩/Python
다음 코드는 subprocess의 check_output함수를 이용해서 실행중인 프로세스의 목록과 간단한 정보를 얻습니다. import subprocess task_list = subprocess.check_output(['tasklist']).decode('cp949', 'ignore').split("\r\n") print(task_list) 이것을 활용해서 특정 이름의 프로세스가 실행중인지, 그리고 그 프로세스의 PID, 실행 유형, 메모리 점유율까지 확인하는 함수를 작성했습니다. 정보를 분리하기 위해 정규식 라이브러리인 re를 추가로 import합니다. import re import subprocess def is_running(name): for task in subprocess.check_out..
[Python] 투네이션 위젯 알림 파이썬으로 가져오기
·
코딩/Python
https://github.com/Sol-Studio/toonation-stream GitHub - Sol-Studio/toonation-stream Contribute to Sol-Studio/toonation-stream development by creating an account on GitHub. github.com 투네이션으로 오는 도네이션을 실시간으로 포착하여 다양한 용도로 활용 가능합니다.
[Python] py 파일을 exe로 변환하기
·
코딩/Python
auto-py-to-exe 설치 $ pip install auto-py-to-exe auto-py-to-exe 실행 $ auto-py-to-exe 변환할 py파일 선택 Script Location 아래의 Browse를 눌러서 변환할 py파일을 선택합니다. 옵션 선택 1. Onfile 아래의 One File을 클릭합니다. 2. tkinter 등 콘솔이 없는 프로그램이라면 Console Window 아래의 Window Based (hide the console)을 클릭합니다 변환 가장 아래의 CONVERT .PY to .EXE를 클릭하고 기다립니다. OPEN OUTPUT FOLDER을 클릭하면 결과물이 있습니다. 끝!
[Python] 관리자 권한 요청하기
·
코딩/Python
import ctypes, sys # 관리자 권한으로 실행되었는지 확인하는 함수 def is_admin(): try: return ctypes.windll.shell32.IsUserAnAdmin() except: return False if is_admin(): # 관리자 권한으로 실행되었을 때 print("I'm ADMIN!") else: # 관리자 권한을 요청하고 다시 실행함 ctypes.windll.shell32.ShellExecuteW(None, "runas", sys.executable, " ".join(sys.argv), None, 1) 관리자 권한을 요청한 후 프로그램이 처음부터 다시 실행되는 점 참고해주세요
파이썬 설치하기
·
코딩/Python
https://www.python.org/downloads/ Download Python The official home of the Python Programming Language www.python.org 위의 링크에 접속합니다 사진처럼 생긴 부분에서 알맞은 버전의 Download 버튼을 누릅니다. (이 블로그에서는 3.8.7 버전을 사용합니다) 페이지 맨 아래의 Files 부분에서 Windows installer (64-bit)을 다운로드받습니다. 다운받은 파일을 실행하면 위와 같은 화면이 나옵니다. 아래의 Add Python 3.x to PATH를 체크해주시고 Install Now를 누릅니다. 조금 기다리면 설치가 완료됩니다.
[PYTHON] PYMONGO 사용하기
·
코딩/Python
0. pip를 사용해서 pymongo를 설치한다 pip install pymongo 1. 모듈 import from pymongo import MongoClient 2. pymongo를 통한 mongo client 연결하기 client = MongoClient("mongodb://127.0.0.1:27017/") 제대로 연결됐는지 확인하기 위해서 db 목록 출력해봅니다 print(client.list_database_names()) 출력 결과는 아래와 같습니다 ['admin', 'local', 'config' ···] 3. find() client["db이름"]["collection이름"].find() collection 안의 모든 데이터를 불러옵니다. 이때 pymongo.cursor.Cursor 객체가..
[디스코드 봇 만들기] part 2 - 봇이 인사하게 만들기(+ 자주 사용되지만 잘 까먹는 변수, 함수들)
·
코딩/Python
2021.05.15 - [프로젝트/[파이썬] 디스코드 봇 만들기] - [디스코드 봇 만들기] part 1 - 봇 생성 오늘은 지난번에 만든 봇이 작동하도록 만들 겁니다. 오늘의 목표는 사용자가 "@안녕"이라고 메시지를 보내면 봇이 대답하는 것입니다. 전체 코드 from discord.ext import commands bot = commands.Bot(command_prefix="") # 봇이 준비되었을때 @bot.event async def on_ready(): await bot.change_presence(status=discord.Status.online, activity=discord.Game("@안녕")) # 봇의 상태를 설정합니다 # 메시지를 받았을 때 @bot.event async def o..
[PYTHON] 바탕화면 바꾸기
·
코딩/Python
import ctypes ctypes.windll.user32.SystemParametersInfoW(20, 0, "사진 경로" , 3) 경로는 전체경로입니다. Windows에서 작동합니다.
[디스코드 봇 만들기] part 1 - 봇 생성
·
코딩/Python
사용 언어(part 2부터 사용) : Python (3.x.x) 디스코드 봇을 만드는 방법입니다. 먼저 아래 링크에 접속합니다. https://discord.com/developers/applications Discord Developer Portal — API Docs for Bots and Developers Integrate your service with Discord — whether it's a bot or a game or whatever your wildest imagination can come up with. discord.com 접속 시 위와 같은 화면이 보이는데, 여기서 오른쪽 위의 New Application을 클릭합니다. 봇의 이름을 정해줍니다. test같은 흔한 이름은 안됩니다..