from turtle import * turtle.setup(600, 400, 10, 10) turtle.bgcolor('red') turtle.hideturtle() turtle.speed(10) turtle.pencolor('yellow') def draw(chang): turtle.fillcolor('yellow') turtle.begin_fill() for i in range(5): turtle.forward(chang) turtle.right(144) turtle.end_fill() def gotopen(x,y): turtle.penup() turtle.goto(x,y) turtle.pendown() gotopen(-250,110) draw(110) gotopen(-100,160) turtle.right(-15) draw(40) gotopen(-60,120) turtle.right(0) draw(40) gotopen(-60,80) turtle.right(15) draw(40) gotopen(-100,40) turtle.right(30) draw(40) turtle.done
取得校园新闻的编号:
a = "http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html" a=a.rstrip(".html") a=a[-9:] print(a)
产生python文档的网址:
def strCat(html,x): b=html[:-11] c=html[-5:] d=b+x+c print(d) strCat("https://docs.python.org/3/library/turtle.html","intro")
产生校园新闻的一系列新闻页网址:
a = "http://news.gzcc.cn/html/xiaoyuanxinwen/4.html" b=a[:-6] c=a[-5:] for i in range(5): d="" d=b+str(i)+c print(d)