# python code by zzw # time:2015-7-27 # for语句注意与其他语言的区别,感觉跟shell有点像 words=[‘dog‘,‘windows‘,‘Linux‘]; for w in words: print(‘the length of ‘,w,‘ is ‘,len(w));
运行结果
the length of dog is 3 the length of windows is 7 the length of Linux is 5
# python code by zzw # time:2015-7-27 # for语句注意与其他语言的区别,感觉跟shell有点像 for i in range(10): print(i);
运行结果
0 1 2 3 4 5 6 7 8 9
# python code by zzw # time:2015-7-27 # for语句注意与其他语言的区别,感觉跟shell有点像 # 这里表示从0开始,步长为3,并且最后一个值小于20 for i in range(0,20,3): print(i);
运行结果:
0 3 6 9 12 15 18
时间: 2024-10-12 02:59:44