字符串练习

http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html

取得校园新闻的编号

str='http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html'
print(str[-14:-5])

https://docs.python.org/3/library/turtle.html

产生python文档的网址

a1="http://doc.python.org/3/library/"
a2=".html"
a3="turtle"
print(a1+a3+a2)

http://news.gzcc.cn/html/xiaoyuanxinwen/4.html

产生校园新闻的一系列新闻页网址

a1 = 'http://news.gzcc.cn/html/xiaoyuanxinwen/'
a2='.html'
for i in range(1,220):
add=a1+str(i)+a2
print(add)

练习字符串内建函数:strip,lstrip,rstrip,split,count

用函数得到校园新闻编号

s='http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html'
print(s.rstrip('.html')[-9:])

原文地址:https://www.cnblogs.com/yh5788lz/p/8618197.html