美文网首页Python四期爬虫作业
【python爬虫】 -第五天

【python爬虫】 -第五天

作者: 黑黑的刘先生 | 来源:发表于2017-08-26 09:35 被阅读8次

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公式,而是抓住正索引和倒索引的方法,学会了从一串字符或者列表,或者元组中查找数据

相关文章

网友评论

    本文标题:【python爬虫】 -第五天

    本文链接:https://www.haomeiwen.com/subject/tedmdxtx.html