기본 콘텐츠로 건너뛰기

라벨이 파이썬인 게시물 표시

mod_wsgi+python3.1

http://code.google.com/p/pywxml/wiki/mod_wsgi python 3.1을 사용하기 위해서는 현재(2009.8.24) 개발버전을 checkout 한 후 win32-ap22py31.mk의 내용을 다음과 같이 수정합니다. checkout svn checkout http ://modwsgi.googlecode.com/svn/trunk/ modwsgi-read-only 수정 CPPFLAGS = \ / DWIN32 \ / DNDEBUG \ / DMOD_WSGI_ENABLE_PY3K \

mod_python 3.3.1

mod_python홈 설치후 아파치 설정에 다음 라인을 추가 후 재시작. LoadModule python_module modules/mod_python.so psp를 사용하기 위해서는 다음 라인도 추가 AddHandler mod_python .psp PythonHandler mod_python.psp

Installing setuptools

installing setuptools 안정적인 버전의 setuptool을 설치하려면 EasyInstall Installation Instructions 을 참조하세요. 파이썬 기본 디렉토리이외에 설치하려면 Custom Installation Locations 부분을 참조하시면 됩니다. 개발버전을 설치하려면 일단 안정버전을 설치한 후 다음을 실행하세요. ez_setup.py setuptools==dev 이 명령은 Python Subversion sandbox에서 개발버전을 다운로드해서 설치합니다.

python sqlite3 db 생성하기

python-sqlite3.html import  sqlite3 # test db(file name) # :memory: means RAM db  =  '''test_db''' sql_t_person  =  '''create table person (name text)''' def  main ():      con  =  sqlite3 . connect ( db )      con . isolation_level  =  None  # autocommit      cur  =  con . cursor ()      # create test_db      cur . execute ( sql_t_person )      cur . close ()      return  0 if  __name__  ==  '__main__' :  main ()

한줄 입력을 Text widget에 출력-grid를 이용

from  tkinter  import  * class  mDialog :      def  __init__ ( self ,  master ):          frame  =  Frame ( master )          frame . pack ()                   #출력을 위한 Text 위젯          self . textbox  =  Text ( frame ,  width = 50 ,  height = 5 )          self . textbox . grid ( row = 0 ,  columnspan = 2 )                   #한줄 입력을 위한 위젯, Entry          self . input  =  Entry ( frame ,  width = 50 )          self . input . grid ( row = 1 ,  column = 0 ) ...

tkinter한줄 입력받아 출력하기

from tkinter import * class App: def __init__(self, master): frame = Frame(master) frame.pack() #한줄 입력을 위한 위젯, Entry self.input = Entry(frame) self.input.pack(side=LEFT) self.button = Button(frame, text="입력", command=self.output) self.button.pack(side=LEFT) def output(self): #입력받은 내용을 출력 #Entry.get() print(self.input.get()) def main(): root = Tk() app = App(root) root.mainloop() if __name__ == '__main__': main()

python tkinter "Hello, world!"

python3.1 from tkinter import * root = Tk() w = Label(root, text="Hello, world!") w.pack() root.mainloop() 결과는 다음과 같습니다.^^ 파이썬 2대에서 모듈명의 첫 대문자 T가 소문자t로 바뀌었습니다.