Created
March 23, 2012 13:16
-
-
Save rswofxd/2170529 to your computer and use it in GitHub Desktop.
List序列
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding:utf-8 -*- | |
s = ['a','b','c','d'] | |
for i in range(len(s)): | |
print(i,s[i]) #代码缩进:tab键值=4个空格 | |
input() | |
#生成以下索引序列 | |
#0 a | |
#1 b | |
#2 c | |
#3 d | |
#>>>range(0,10,3) 范围0~10,步长为3的序列 | |
# 0,3,6,9 | |
#>>>print(range(5)) | |
# range(0,5) 非列表,节省空间 | |
#>>>list(range(5)) | |
# [0,1,2,3,4] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment