본문 바로가기

Language/python

(72)
xlwt - Excel 생성 모듈 목차 xlwt 소개 xlwt 사용법 기본 사용법 사용 예제 1 : Cell에 Overwrite 하기 사용 예제 2 : 서식 바꾸기 참고 xlwt 소개# pyExcelerator의 클론 프로젝트이며, COM 또는 엑셀의 설치가 없더라도 엑셀 파일을 생성을 가능하게 해주는 파이썬 모듈이다. 즉, 리눅스를 포함한 다른 플랫폼에서의 사용이 가능하다. 다운로드는 아래의 홈페이지에서 최신 버전을 받는다. http://pypi.python.org/pypi/xlwt 별도의 문서가 있는것이 아니라, 예제를 통해서 사용방법을 익혀야 한다. 예제 파일들은 아래의 위치에서 확인가능하다. https://secure.simplistix.co.uk/svn/xlwt/trunk/xlwt/examples/ xlwt 사용법# 기본 사용법..
그냥.. Producer/Consumer Python 예제 import Queue import copy import threading import time mq = Queue.Queue(256) mtx_print = threading.RLock() def safe_print(str): mtx_print.acquire(True) print str mtx_print.release() class ProducerThread(threading.Thread): def __init__(self): threading.Thread.__init__(self) def run(self): a = [1,2,3] for i in range(10): mq.put(copy.deepcopy(a), True, 1) safe_print("Producer : Sent %d" % (i+1)) tim..
python 설치후 설치하는 패키지들 matplotlib numpy beautifulsoup
BeautifulSoup 설치 1. http://www.crummy.com/software/BeautifulSoup/ 에서 최신 BeautifulSoup.tar.gz 다운로드 받는다. 2. 압축을 해제하고 BeautifulSoup.py를 PYTHON_PATH에 잡힌 아무곳이나 복사를 한다. -_- (python이 설치된 디렉토리의 Lib\site-packages 에 복사한다.) ps) BeautifulSoup3 설치에 대한 글이다. pip로 설치하는 것을 추천한다.pip 설치 : http://ppiazi.tistory.com/entry/pip-%EC%84%A4%EC%B9%98BeautifulSoup4 설치하기 : http://ppiazi.tistory.com/entry/BeautifulSoup-4
SWIG Tutorial 목차 시작하기 Interface file Building a Tcl module Building a Python module Building a Perl module Building a Java module Building a C# module SWIG for the truly lazy Running SWIG under Microsoft Windows That's it (well, more or less) Surely there's more to it... 원본 : http://www.swig.org/tutorial.html 시작하기# 짧은 시간내에 SWIG를 사용해보자. SWIG를 사용법을 설명하기 전에 변환하기를 원하는 C 파일을 가지고 있고 이것을 Tcl, Perl, Python, Java, C#에..
matplotlib Cookbook 목차 Simple Plotting Sigmoidal Functions Multiple line Plots Multiline Plots Using multiple axes Manipulating transforms Bar Charts Load and Display Image 3D Interactive Plotting 원문 : http://www.scipy.org/Cookbook/Matplotlib?action=show&redirect=wikis%2Ftopical+software%2FMatplotlibCookbook Simple Plotting# Sigmoidal Functions# matplotlib을 사용하여 어떤 함수를 그릴려면, 그리고자 하는 함수의 x축, y축 쌍의 점들을 계산하여야 한다. 계산된 ..
pywinauto를 사용하여 윈도우 어플리케이션 제어하기 제품 수락검사를 수행하다보면, 자동화 테스팅 툴의 필요함이 절실하다. 하나만 테스트 하면 모르겠지만 동일 제품을 수십개를 동일한 테스트를 수행해야 할 경우는 더욱더 그렇다!! 이렇게 고민하다 발견한 모듈이 pywinauto 이다. 파이썬 모듈이며, 만든이도 테스팅을 전문으로 하시는 분이다. 사용법은 매우 직관적이고 간단하다. 기존에 떠있는 윈도우에 attach 시키기 위해서는 connect_ 를 사용하면 되고, 새롭게 실행하려면, start_를 사용하면된다. howto문서가 잘되있어서, 보고 따라하면 금새 사용방법을 알 수 있다. 모든 윈도우 컨트롤에 대한 API 또한 준비되어 있다. 이 링크는 동영상으로 Notepad를 pywinauto로 컨트롤하는 과정을 동영상으로 확인할 수 있다.
win32file - Windows에서 파일 속성 확인 및 수정 하는 방법 회사 보안 감사 때문에, 암호화되지 않은 문서들 일괄 처리 스크립트를 작성중에 Read-Only 속성 걸린 파일 때문에 골치를 썩었다. (이럴때마다, 난 파이썬의 도움을 받곤한다. ㄳㄳ) 간단한 구글링을 통해 아래의 방법으로 Read-Only 속성을 포함한 윈도우 파일 속성을 처리하는 방법을 아래와 같이 정리한다. Win32 Extension for Python을 설치한다. http://starship.python.net/~skippy/win32/Downloads.html 사용되는 API는 다음과 같다. win32file.GetFileAttributes(file_name) win32file.SetFileAttributes(file_name, new_fattr) 사용되는 속성들은 다음과 같다. win32f..