Python基础综合练习
Posted 091梁耀
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了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))
以上是关于Python基础综合练习的主要内容,如果未能解决你的问题,请参考以下文章