2 Star 3 Fork 3

celaraze / learning-python

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
Clone or Download
9.切片.py 185 Bytes
Copy Edit Raw Blame History
绯末 authored 2019-12-27 11:30 . 补全函数;增加切片
# 取列表中前2个元素
# 倒数索引从-1开始
l = ['Tom', 'Tracy', 'Thomas', 'Allen']
print(l[0:2])
# 字符串也可以看成list来做切片
name = 'Thomas'
print(name[1:4])
Python
1
https://gitee.com/celaraze/learning-python.git
git@gitee.com:celaraze/learning-python.git
celaraze
learning-python
learning-python
master

Search