转载请标明出处:
http://www.cnblogs.com/why168888/p/6407977.html

本文出自:【Edwin博客园】


1. 对list进行切片

L = range(1, 101)
print L[:10]
print L[2::3]
print L[4:50:5]

2. 倒序切片

L = range(1, 101)
print L[-10:]
print L[-46::5]

3. 对字符串切片

def firstCharUpper(s):
    return s[0].upper() + s[1:]
print firstCharUpper('hello')
print firstCharUpper('sunday')
print firstCharUpper('september')

相关文章:

  • 2022-01-02
  • 2022-12-23
  • 2021-12-19
  • 2022-12-23
  • 2022-12-23
  • 2021-07-07
  • 2021-12-31
  • 2021-05-28
猜你喜欢
  • 2021-09-20
  • 2022-12-23
  • 2022-01-06
  • 2022-02-06
  • 2022-02-09
  • 2022-12-23
相关资源
相似解决方案