전체 글

function init(){ testWebSocket(); } function testWebSocket(){ websocket = new WebSocket("ws://echo.websocket.org"); // 웹소켓 서버 주소로 변경 websocket.onopen = function(evt){ onOpen(evt) }; websocket.onclose = function(evt){ onClose(evt) }; websocket.onmessage = function(evt){ onMessage(evt) }; websocket.onerror = function(evt){ onError(evt) }; } function onOpen(evt){ // 소켓이 열렸을 때 실행될 함수 } function onCl..
#1 CMD 명령어 실행 import os os.system("명령어") CMD창에서 명령어를 입력한것과 같게 작동합니다. 실행 위치는 파이썬 프로그램의 실행위치와 같습니다. #2 CMD 명령어 실행과 결과 얻기 import subprocess result = subprocess.getstatusoutput("명령어") CMD창에서 명령어를 입력한것과 같게 작동합니다. 실행 위치는 파이썬 프로그램의 실행위치와 같습니다. 실행 결과는 result 변수에 저장됩니다.
import base64 base64.decode(open("원본 파일 경로"), open("디코드된 결과물이 나올 경로")) base64.encode(open("원본 파일 경로"), open("인코드된 결과물이 나올 경로")) base64로 디코드, 인코드 할 수 있습니다.
import getpass user_name = getpass.getuser() print(user_name) 현재 로그인되어있는 windows 사용자의 이름을 가져옵니다.
import ctypes lib = ctypes.windll.LoadLibrary('user32.dll') handle = lib.GetForegroundWindow() buffer = ctypes.create_unicode_buffer(255) lib.GetWindowTextW(handle, buffer, ctypes.sizeof(buffer)) active = buffer.value print(active) active 변수가 활성화된 창의 제목입니다.
import turtle as t import time # x, y축 그리기 t.pendown() t.goto(0, 1000) t.goto(0,0) t.goto(1000,0) t.penup() # 준비 x, y = 1, 1 x += 1 y = 400 // x t.goto(x, y) t.pendown() # 그래프 그리기 for i in range(600): t.goto(x, y) x += 1 y = 2000 // x print(x, y)
· 코딩
# 숫자는 순위가 아닙니다 1. VSC (Visual Studio Code) code.visualstudio.com/ Visual Studio Code - Code Editing. Redefined Visual Studio Code is a code editor redefined and optimized for building and debugging modern web and cloud applications. Visual Studio Code is free and available on your favorite platform - Linux, macOS, and Windows. code.visualstudio.com 장점 : 다양한 언어를 지원함, 중간 정도 가벼움 단점 : 모르겠다 2. Sublim..
1. 클라이언트의 IP주소 # IP 가져오기 request.environ.get('HTTP_X_REAL_IP', request.remote_addr) 2. 클라이언트가 요청한 전체 url # 요청한 url request.full_path 3. 클라이언트가 요청한 method # http 메소드(GET 또는 POST) request.method 4. POST요청 처리 form 태그 안에 있는 입력 태그중 name이 title인 태그의 값을 가져옴 request.form.get('title') 5. GET요청 처리 # http://example.com/?name=값 에서 값을 가져옴 request.args.get("name") 6. 대략적인 정보 # str(request) 댓글 오류지적 환영합니다.
from tkinter import Tk, Label # 창 생성 window = Tk() # 레이블 생성 label = Label(window, text="hello world!") # 레이블을 창에 배치 label.pack() # 텍스트 속성을 변경 (= configure) label.config(text="changed!") # 메인루프 window.mainloop() 더보기 파이썬 tkinter label 텍스트 글자 문장 넣기 윈도우 gui
# import from PIL import ImageGrab # 캡쳐 screen = ImageGrab.grab() # 캡쳐된 사진의 point좌표의 색상값을 가져옴 color = screen.getpixel(point) """ point : (x,y) color : (r,g,b) """ 더보기 파이썬 화면 픽셀 색깔 색상 rgb
Sol Studio 공식 블로그
sol-studio