Skip to content

Instantly share code, notes, and snippets.

@rswofxd
Created March 23, 2012 13:16
Show Gist options
  • Save rswofxd/2170529 to your computer and use it in GitHub Desktop.
Save rswofxd/2170529 to your computer and use it in GitHub Desktop.
List序列
# -*- 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