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

上一篇:linq 实现group by 不使用group关键字 等同lambad表达式中的group join 查询一对多关系


下一篇:c#多线程随记回顾