资源预览内容
第1页 / 共32页
第2页 / 共32页
第3页 / 共32页
第4页 / 共32页
第5页 / 共32页
第6页 / 共32页
第7页 / 共32页
第8页 / 共32页
第9页 / 共32页
第10页 / 共32页
亲,该文档总共32页,到这儿已超出免费预览范围,如果喜欢就下载吧!
资源描述
Python web 开发介绍,2014.12.22DBA 王洪权,内容概要,一 python简介二 python常用的数据结构(字符串,元组,字典,列表,函数,类,继承,模块引用,文件操作)三 Django web框架介绍四 Django 实例五 DevOps 文化,Python(英语发音:/pan/), 是一种面向对象、解释型计算机程序设计语言,由Guido van Rossum于1989年底发明,第一个公开发行版发行于1991年,Perl Java Python Ruby PHP1987 19901994 1991 1993 1995,python简介,Python现在成为美国名校中最流行的编程入门语言,Python是美国大学计算机科学系入门课程最受欢迎的编程语言。计算机科学系Top10中有8家Top39中24家,在入门课程中教授Python (2014年7月调查统计)。,python简介,过程概述Python先把代码(.py文件)编译成字节码,交给字节码虚拟机,然后虚拟机一条一条执行字节码指令,从而完成程序的执行。,python简介,Python程序的执行原理,Life is short, you need Python -Bruce Eckel,python简介,无需声明变量value = 20print value20value = 100.23print value100.23value = Hello world“print value * 3Hello worldHello worldHello world,Python语法,pythonprint Hello WorldHello World,Javavi HelloWorld.java public class HelloWorld public static void main(String args) System.out.println(Hello World!); javac HelloWorld.java java HelloWorldHello World!,name = raw_input(what is you name?),print hello,name,welcom to you,hello jack welcom to you,Python-输入,Python数据结构-字符串,name = Arul,name0Amyname = Arul + alan Arulalan,name = This is python stringname.split( ) This, is, python, stringcomma = Shrini,Arul,Sureshcomma.split(,) Shrini, Arul, Suresh,li = a,b,c,dnew = -.join(li) a-b-c-dnew.split(-) a, b, c, d,small.upper()SMALLBIG.lower() bigmIxEd.swapcase()MiXwD,Python数据结构-列表,numbers = one, two, three, four,five ,print numbers0oneprint numbers4fiveprint numbers2threeprint len(numbers) 5,primes = 11, 5, 7, 2, 13, 3 primes.sort() 2, 3, 5, 7, 11, 13primes.append(14)print primes2, 3, 5, 7, 11, 13, 14,primes.reverse()print primes14, 13, 11, 7, 5, 3, 2,price = apple,10,banana,30 price1+2030 price2.upper()BANANA,item = iphone : 5999,huaiwei : 3000,xiaomi : 2999,meizu : 1999 itemiphone5999 itemmeizu1999 item.get(lenove,None)None, item.keys()meizu, huaiwei, iphone, xiaomi item.values()1999, 3000, 5999, 2999 for key,value in item.iteritems():. print key,= ,value. meizu = 1999huaiwei = 3000iphone = 5999xiaomi = 2999,Python数据结构-数据字典,Python数据结构-元组,names=(hello,world,hey)names.append(222)AttributeError: tuple object has no attribute append,Python数据结构-函数,def printMax(a, b): if a b: print a, is maximum else: print b, is maximum printMax(3, 4)4 is maximum,def sayHello(): print Hello World!, sayHello()Hello World!,Python数据结构-类,class Person: pass p = Person()print p= 5000 : print “You win!”elif score = 0 : print “You lose!” print “Game over.”else: print “Current score:”,score print “Donen”,Python-条件判断,Python-循环,for i in range(1, 5): print i1234,number = 23running = Truewhile running : guess = int(raw_input(Enter an integer : ) if guess = number : print Congratulations, you guessed it. running = False elif guess import time time.sleep(10) print the time is startthe time is start time.sleep(10) print the time is endthe time is end, import os os.listdir(/home/) otp_src_R16B02.tar.gz, mysql_percona, mysql,rabbitmq os.mkdir(/home/helloworld) os.listdir(/home/)otp_src_R16B02.tar.gz, mysql_percona, mysql, helloworld, rabbitmq,Python-引用模块,vi demo.py#!/usr/local/bin/pythondef hi(): print hello,welcome!version = 0.11,vi demo1.py #!/usr/local/bin/pythonimport demodemo.hi()print version,demo.version,python demo1.py hello,welcome!version 0.11,vi demo1.py #!/usr/local/bin/pythonfrom demo import hi,versionhi()print version,version,python demo1.py hello,welcome!version 0.11,cat test.txt 12345cat file.py f = file(test.txt,r)for line in f.readlines(): print line.strip(n)f.close()python file.py12345,Python-文件操作,cat filewrite.pyf=file(test1.txt,w)for i in range(11): f.write(str(i)+n)f.close()python filewrite.py012345678910,
收藏 下载该资源
网站客服QQ:2055934822
金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号