Python基础综合练习

 1 import turtle
 2 from turtle import *
 3 
 4 
 5 def mygoto1(x, y):
 6     turtle.up()
 7     turtle.goto(x, y)
 8     turtle.down()
 9 
10 
11 def star(r):
12     turtle.begin_fill()
13     for i in range(5):
14         turtle.forward(r)
15         turtle.right(144)
16     turtle.end_fill()
17 
18 
19 turtle.setup(700, 500)
20 turtle.bgcolor('red')
21 turtle.color('yellow')
22 turtle.speed(8)
23 turtle.fillcolor('yellow')
24 turtle.hideturtle()
25 
26 
27 mygoto1(-300, 150)
28 star(100)
29 mygoto1(-190, 220)
30 star(45)
31 mygoto1(-140, 150)
32 star(45)
33 mygoto1(-140, 90)
34 star(45)
35 mygoto1(-190, 40)
36 star(45)
37 done()

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

str1 = 'http://news.gzcc.cn/html/xiaoyuanxinwen/'
str2 = '.html'

for i in range(1,10):
str3 = str1 + str(i) + str2
print(str3)

取得校园新闻的编号

str1 = 'http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html'

print(str1[-14:-5])


字符串內建函数
str1 = 'http://news.gzcc.cn/html/2017/xiaoyuanxinwen_1027/8443.html'
a = ' this is string example....wow!!! '
print(a.lstrip())
print(a.strip())
print(a.lstrip().lstrip('this'))
print(str1.rstrip('.html'))
print(str1.rstrip('.html')[-9:-1])
print(a.split())
print(a.split('i'))



https://docs.python.org/3/library/turtle.html
产生python文档的网址

for i in range(2,,10):
print('https://docs.python.org/3/library/{}.html'.format(i))
原文地址:https://www.cnblogs.com/liangyao111/p/8600903.html