파이썬으로 구현한 간단한 메모장 프로그램 소스 예제입니다. 각자 코드를 다듬어서 좀 더 성능 좋은 메모장으로 만들어보세요. import tkinter as tk from tkinter import filedialog class Notepad: def __init__(self, master): self.master = master self.filename = None self.text = tk.Text(self.master) self.text.pack(fill="both", expand=True) self.create_menu() def create_menu(self): menubar = tk.Menu(self.master) filemenu = tk.Menu(menubar, tearoff=0) fileme..
Python으로 CPU Core 갯수 얻는 방법 (os) Mac address 얻는 방법 (uuid) import os, re, uuid print( "Number of CPU: ", os.cpu_count() ) print( "MAC Address : ",':'.join(re.findall('..', '%012x' % uuid.getnode())) ) 결과: Number of CPU: 8 MAC Address : 12:34:56:78:9a:bc
1. pycrypto 설치필요 pip install pycrypto 2. 암호화, 복호화 클래스 import base64 import hashlib from Crypto.Cipher import AES BS = 16 pad = (lambda s: s + (BS - len(s) % BS) * chr(BS - len(s) % BS).encode()) unpad = (lambda s: s[:-ord(s[len(s)-1:])]) class AESCipher(object): def __init__(self, key): self.key = hashlib.sha256(key.encode()).digest() def encrypt(self, message): message = message.encode() raw = ..
#Python3 #!pip install pdfminer from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter from pdfminer.pdfpage import PDFPage from pdfminer.converter import TextConverter from pdfminer.layout import LAParams from io import StringIO def pdf_to_text(pdfname): # PDFMiner boilerplate rsrcmgr = PDFResourceManager() sio = StringIO() codec = 'utf-8' laparams = LAParams() device = TextConve..
URL: http://code.activestate.com/recipes/52281/ Sometimes we are getting HTML input from the user. We want to only allow valid, undangerous tags, we want all tags to be balanced (i.e. an unclosed will leave all text on your page bold), and we want to strip out all Javascript. This recipe demonstrates how to do this using the sgmllib parser to parse HTML. Python, 59 lines Download import sgmllib,..