博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python基础综合练习
阅读量:5925 次
发布时间:2019-06-19

本文共 2957 字,大约阅读时间需要 9 分钟。

1 import turtle 2   3 def mygoto(x,y): 4     turtle.up() 5     turtle.goto(x,y) 6     turtle.down() 7   8 def drawwjx(x): 9     turtle.begin_fill()10     for i in range(5):11         turtle.forward(x)12         turtle.right(144)13     turtle.end_fill()14 15 turtle.speed(10)16 turtle.color("red")17 mygoto(-300,200)18 turtle.begin_fill()19 for i in range(2):20  turtle.forward(576)21     turtle.right(90)22     turtle.forward(384)23     turtle.right(90)24 turtle.end_fill()25  26 turtle.color("yellow")27 mygoto(-262,123)28 drawwjx(110)29  30 for i in range(4):31     x=132     if i in [0,3]:33         x=034     mygoto(-120+x*30, 160-i*41)35     turtle.left(15-i*15)36     drawwjx(30)37  38 turtle.hideturtle()39 turtle.done()

 

 

字符串练习:

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

取得校园新闻的编号

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

 

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

产生python文档的网址

 

url ="https://docs.python.org/3/library/turtle.html"print(url.replace("turtle","python"))

  

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

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

for i in  range(2,10):    print('http://news.gzcc.cn/html/xiaoyuanxinwen/{}.html'.format(str(i)));

 

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

用函数得到校园新闻编号

url ="http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html"print (url.split('_',2)[1].rstrip(".html"))

 

用函数统计一歌词(文章、小说)中单词出现的次数,替换标点符号为空格,用空格进行分词

Let it go

Let it go

Can't hold you back anymore

Let it go Let it go Turn my back and slam the door . The snow blows white on the mountain tonight Not a footprint to be seen A kingdom of isolation and it looks like I'm the Queen The wind is howling like the swirling storm inside Couldn't keep it in, heaven knows I tried Don't let them in, don't let them see Be the good girl You always had to be Conceal, don't feel Don't let them know Well, now they know . Let it go Let it go Can't hold you back anymore Let it go Let it go Turn my back and slam the door And here I stand, and here I'll stay Let it go Let it go The cold never bothered me anyway . It's funny how some distance Makes everything seem small And the fears that once controlled me Can't get to me at all Up here in the cold thin air I finally can breathe I know i left a life behind but I'm to relieved to grieve . Let it go Let it go Can't hold you back anymore Let it go Let it go Turn my back and slam the door And here I stand And here I'll stay Let it go Let it go The cold never bothered me anyway . Standing frozen in the life  chosen You won't find me, the past is so behind me Buried in the snow . Let it go Let it go Can't hold you back anymore Let it go Let it go Turn my back and slam the door And here I stand And here I'll stay Let it go Let it go The cold never bothered me anyway na na na na na na Let it go na na na you go Let it go Let it go Let it go
1 print(str.count("go"))2 print(str.replace(","." "))

 

 

 

 

转载于:https://www.cnblogs.com/xiaozheng303/p/8620076.html

你可能感兴趣的文章
【路由策略与策略路由的区别】
查看>>
vSphere HA
查看>>
tracertroute原理
查看>>
Mysql存储过程编写
查看>>
使用zabbix模板监控tomcat-解决模板部分监控项不生效问题
查看>>
Myslq 启动报错The server quit without updating PID file
查看>>
tomcat
查看>>
memcached安装配置
查看>>
2013年下半年信息系统项目管理师考试试卷(回忆版)
查看>>
我的友情链接
查看>>
为什么很多大学生毕业后都说大学所学知识无用?
查看>>
oracle goldengate使用测试
查看>>
求斐波那契数列的第n项值——9
查看>>
闲话IPv6地址
查看>>
std::function与std::bind 函数指针
查看>>
Git and GitHub
查看>>
ajax中同步和异步的使用
查看>>
BarTender数据中的转义符序列知识讲解
查看>>
selenium - switch_to_alert() - 警告框处理
查看>>
sp获取用户权限,打印出批量赋权语句
查看>>