码迷,mamicode.com
首页 > 编程语言 > 详细

python学习过程中随手写的测试脚本-testloop.py

时间:2017-09-13 18:30:03      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:数组   pytho   test   手写   for   list   stl   end   break   

## 定义list数组
lstrs = [‘t1‘,‘t2‘,‘t3‘,‘t4‘]
print(‘lstrs is‘,lstrs)

i = 0
## test for loop
for lstr in lstrs:
print(‘lstrs[%d] is‘ % i,lstr )
i = i + 1
print(‘end for loop‘)

j = 0
## test while loop
while j <= 3:
print(‘lstrs[%d] is‘ % j,lstrs[j] )
j = j + 1
print(‘end while loop‘)

k = 0
## test break and continue
print(‘k=0 , k<=10 ,1 continue, k>=4 break‘)
while k <= 10:
if k == 1:
k = k + 1
continue
print(‘k is %d‘ % k)
if k >= 4:
break
k = k + 1
print(‘end test for break and continue‘)

python学习过程中随手写的测试脚本-testloop.py

标签:数组   pytho   test   手写   for   list   stl   end   break   

原文地址:http://www.cnblogs.com/dcbook/p/7516339.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!