【python爬虫】 -第五天

str1='http://www.jianshu.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])

以下为编译结果:

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)



第五天教学较为简单。需要记住的不是python公式,而是抓住正索引和倒索引的方法,学会了从一串字符或者列表,或者元组中查找数据

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容