1.字符串练习:
http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html
取得校园新闻的编号
acc="http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html" print(acc[-14:-5])
https://docs.python.org/3/library/turtle.html
产生python文档的网址
abb1="http://doc.python.org/3/library/" abb2=".html" abb3="turtle" print(abb1+abb3+abb2)
http://news.gzcc.cn/html/xiaoyuanxinwen/4.html
产生校园新闻的一系列新闻页网址
add1="http://news.gzcc.cn/html/xiaoyuanxinwen" add2=".html" for i in range(2,10): add=add1 + str(i) + add2 print(add)
练习字符串内建函数:strip,lstrip,rstrip,split,count
用函数得到校园新闻编号
a="http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html" print(a.rstrip(".html").split("_")[1])
用函数统计一歌词中单词出现的次数
song=‘‘‘
sunday‘s coming i wanna drive my car
to your apartment with present like a star
forecaster said the weather may be rainy hard
but i know the sun will shine for us
oh lazy seagull fly me from the dark
i dress my jeans and feed my monkey banana
then i think my age how old,skyline how far
or we need each other in california
you show me your body before night comes down
i touch your face and promise to stay ever young
on this ivory beach we kissed so long
it seems that the passion‘s never gone
you sing me your melody and i feel so please
i want you to want me to keep your dream
together we‘ll run wild by a summer symphony
this is what we enjoyed not a fantasy
the tin-man‘s surfing i wanna try my luck
to the top of tide rip like just have some drugs
i know you have no blame for my proud moonish heart
welcom to the golden beatnik park
oh diamond seashore drag me from the yard
incredible sunward i watch as you‘re in photograph
for camera your smile‘s so sweet,palm trees‘ so lush
would you believe my honey it‘s califonia
you show me your body before night comes down
i touch your face and promise to stay ever young
on this ivory beach we kissed so long
it seems that the passion‘s never gone
you sing me your melody and i feel so please
i want you to want me to keep your dream
together we‘ll run wild by a summer symphony
this is what we enjoyed not a fantasy
‘‘‘ print(‘the在歌曲里一共出现了‘+ str(song.count(‘the‘)) +‘次‘)
将字符串分解成一个个的单词。
s=‘it seems that the passion‘s never gone‘ s.split()