这一节,我们将学习Python的控制流语句,主要包括if.for.while.break.continue 和pass语句 1. If语句 if语句也许是我们最熟悉的语句.其使用方法如下: x=input("please input an integer:") if x<0: print 'x<0' elif x==0: print 'x=0' elif x>0: print 'x>0' else: print ' x is not an number' 运行…
本篇只是拿一段代码来对python中的字符串的一些使用做解释,来让大家更加了解python Python 3.4.0 (v3.4.0:04f714765c13, Mar 16 2014, 19:25:23) [MSC v.1600 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> pystr=…
1. cat func.py #!/usr/bin/python def func(): print "hello,this is a function" def func2(): for i in range(10): print "this will show function 10 times" func() def addtion(): sum=2+1 print "1 + 1 = %s" %sum func2() addtion() 2…