list 切片、字符串切片

1、list和tuple 切片:

a=range(100)

a[0:]= 1--99

a[1:10]=1--9

a[1:50:2]=1,3,5.。。。

a[-1:]=99

a[-100:]=0--99

a[-100:-50:2]=0,2,4,6......

字符串切片操作也是一样的

def firstCharUpper(s):
return s[0].upper()+s[1:]

print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')

原文地址:https://www.cnblogs.com/zhzhao/p/4236539.html