str1='http://www.reibang.com/u/2cbfb62a28a8'
str2=str1.split('/')[-1]
print(str2)
s ="abcdefg"
print(s[3])
print(s[2:4])
print(s[:5])
print(s[3:])
print(s[::1])
print(s[::2])
list1 = [1,2,3,4,5,6,7]
print(list1[3])
print(list1[2:4])
print(list1[:5])
print(list1[3:])
print(list1[::-1])
print(list1[::2])
touple1 = (1,2,3,4,5,6,7)
print(touple1[3])
print(touple1[2:4])
print(touple1[:5])
print(touple1[3:])
print(touple1[::-1])
print(touple1[::2])
以下為編譯結(jié)果:
2cbfb62a28a8
d
cd
abcde
defg
abcdefg
aceg
4
[3, 4]
[1, 2, 3, 4, 5]
[4, 5, 6, 7]
[7, 6, 5, 4, 3, 2, 1]
[1, 3, 5, 7]
4
(3, 4)
(1, 2, 3, 4, 5)
(4, 5, 6, 7)
(7, 6, 5, 4, 3, 2, 1)
(1, 3, 5, 7)
第五天教學(xué)較為簡(jiǎn)單。需要記住的不是python公式书在,而是抓住正索引和倒索引的方法筛严,學(xué)會(huì)了從一串字符或者列表压固,或者元組中查找數(shù)據(jù)