Python基础综合练习

# -*- coding: UTF-8 -*-
import turtle

def mygoto(x,y):
    turtle.up()
    turtle.goto(x,y)
    turtle.down()
def drawwu(x):
    turtle.begin_fill()
    for i in range(5):
        turtle.forward(x)
        turtle.right(144)
    turtle.end_fill()
turtle.setup(600,400,0,00)
turtle.color('yellow')
turtle.bgcolor('red')
turtle.color('yellow')
turtle.speed(10)
mygoto(-220,95)
drawwu(100)

for i in range(4):
    x=1
    if i in [0,3]:
        x=0
    mygoto(-100+x*50,150-i*40)
    turtle.left(15 - i * 15)
    drawwu(50)
turtle.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))



  

posted @ 2018-03-19 09:40  089-袁佳鹏  阅读(160)  评论(0编辑  收藏  举报