Download presentation
Presentation is loading. Please wait.
Published byJahiem Pixton Modified over 10 years ago
1
Python 20021080 Hyunjong Lee
2
contents Introduction Syntax & data types Tools Python as CGI
3
Introduction Developed by Guido Van Rossum in 1990 Interpret based language Has simple syntax Dynamic type binding Embedded high level data structure Garbage collection Module structure (glue language) Fast development cycle
4
Syntax Syntax is very simple Similar to most of other languages Indentation sensitive
5
High level built-in data types Complex number List (can be nested) Tuples Dictionary
6
Tools Py2exe – convert python script into exe file Python2c – convert python script into C source file SWIG(simplified wrapper and interface generator) – glue code generator
7
Python as CGI #!/usr/bin/python import cgi#import CGI module print "Content-Type: text/plain\n\n" The_Form = cgi.FieldStorage() for name in The_Form.keys(): print "Input: " + name print " value: " + The_Form[name].value + “\n” print "Finished!“ email: name: email: name:
8
Python as CGI template.html <html><head> Python is Fun! Python is Fun! </head><body> </body></html>
9
Python as CGI #!/usr/bin/python #!/usr/bin/python import re #import regular expression module import cgi TemplateFile = "template.html" # Display function def def Display(Content): fp = open(TemplateFile, "r") TemplateInput = fp.read() #open & read entire file fp.close() BadTemplateException = “problem in template file" SubResult = re.subn(" ", Content,TemplateInput) if SubResult[1] == 0: raise BadTemplateException print "Content-Type: text/html\n\n“ print SubResult[0] #make dynamic contents here …
10
Python as CGI import MySQLdb# import SQL module connection = MySQLdb.connect(user=‘uuu', passwd=‘ppp', db=‘db') cursor = connection.cursor() cursor.execute(“SELECT * FROM some_table”) cursor.close()
11
References http://www.python.or.kr/
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.