zoukankan      html  css  js  c++  java
  • Python基础综合练习


    import turtle def mygoto(x, y): turtle.up() turtle.goto(x,y) turtle.down() def drawBigStar(x): turtle.begin_fill() for i in range(5): turtle.forward(x) turtle.right(144) turtle.end_fill() def drawStar(x): turtle.begin_fill() for i in range(5): turtle.forward(x) turtle.left(144) turtle.end_fill() mygoto(-250,200) turtle.color("red") turtle.fillcolor("red") turtle.begin_fill(); for i in range(2): turtle.forward(600) turtle.right(90) turtle.forward(400) turtle.right(90) turtle.end_fill() mygoto(-220,110) turtle.color("yellow") turtle.fillcolor("yellow") turtle.begin_fill() drawBigStar(100) turtle.end_fill() for i in range(4): x=1 if i in[0,3]: x=0 mygoto(-100+x*50,150-i*45) turtle.left(15-i*15) drawBigStar(30) mygoto(0,0) turtle.hideturtle() 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])

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

    产生python文档的网址

    addr1 = 'https://docs.python.org/3/library/'
    addr2 = '.html'
    addr = addr1 + 'turtle' + addr2
    print(addr)
    

      

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

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

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

      

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

    用函数得到校园新闻编号

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

      

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

      

  • 相关阅读:
    如何统计一个字符串中某个字符出现的次数
    从GitHub克隆项目到本地
    nginx能做什么
    dubbo的使用实例
    zookeeper单机安装
    Http发送post(x-www-form-urlencoded)请求
    集群与分布式的区别
    cas的客户端应用是负载均衡,单点退出怎么办?
    mybatis执行DDL语句
    sql server 行列互换
  • 原文地址:https://www.cnblogs.com/932zdb/p/8610220.html
Copyright © 2011-2022 走看看