zoukankan      html  css  js  c++  java
  • python练习

    1:画五角星
    import turtle turtle.bgcolor('red') turtle.fillcolor('yellow') turtle.pencolor('yellow') def draw(x): turtle.begin_fill() for i in range(5): turtle.forward(x) turtle.right(144); turtle.end_fill() def go(x, y): turtle.up() turtle.goto(x, y) turtle.down() go(-200,100) draw(100) go(-100, 200) draw(50) go(-50, 150) draw(50) go(-50, 80) draw(50) go(-100, 10) draw(50) turtle.hideturtle() input()

      

    2:取得校园新闻的编号

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

     3:产生python文档的网址

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

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

    产生校园新闻的一系列新闻页网址
    url1 = "http://news.gzcc.cn/html/xiaoyuanxinwen/"
    url2 = ".html"
    for i in range(2,10):
    url= url1 + str(i) + url2
    urlstr= "http://news.gzcc.cn/html/xiaoyuanxinwen/{}.html".format(i)
    print(urlstr,url)

    5:lsrip()函数、count()函数、replace()函数的使用

    str=' hhh kkk jakshdf kk nnh dd ss gg tt ss '

    'ff you you ni ni nin me me eme eme e e'
    ' ee e e e e e e e e nnn bb hh kk kk n hh '
    'hh jj ss aa cc vv '
    print(str.lstrip())
    print(str.count('me'))
    print(str.replace('ee','=='))

    结果显示:

    hhh kkk jakshdf kk nnh dd ss gg tt ss ff you you ni ni nin me me eme eme e e ee e e e e e e e e nnn bb hh kk kk n hh hh jj ss aa cc vv
    4
              hhh kkk jakshdf kk nnh dd ss gg tt ss ff you you ni ni nin me me eme eme e e == e e e e e e e e nnn bb hh kk kk n hh hh jj ss aa cc vv

  • 相关阅读:
    DockerFile体系结构
    Nignx(二) server_name 规则
    解决Redis分布式锁——死锁问题
    redis缓存穿透,缓存击穿,缓存雪崩原因+解决方案
    Docker_Linux
    正则例子
    部属流程
    Mysql insert语句的优化
    MySQL innodb_fast_shutdown参数讲解
    MySQL技术内幕InnoDB存储引擎(表&索引算法和锁)
  • 原文地址:https://www.cnblogs.com/qq1141100952com/p/8610996.html
Copyright © 2011-2022 走看看