标签:python中for循环
打印出1到100的数,不包含100
for i in range(1,100):
if i==23:
print "great,you got your luncky number:",i
print ‘The unmber is:‘,i
================23会被重复打印===============================
for i in range(1,100):
if i==23:
print "great,you got your luncky number:",i
else:
print "The unmber is:",i
================23只会打印一次===============================
for i in range(1,100):
if i==23:
print "great,%s lucky number:"%i #%s,引用外部的变量;外部的变量则为:引号之外的变量
print "The number is:",i
标签:python中for循环
原文地址:http://11143863.blog.51cto.com/11133863/1737316