函数定义与使用,字符串类型

import turtle
turtle.setup(600,400,0,0)

turtle.bgcolor('red')
turtle.pencolor('yellow')
turtle.fillcolor('yellow')

def mygoto(x,y):
    turtle.penup()
    turtle.goto(x,y)
    turtle.pendown()

mygoto(-250,100)
turtle.begin_fill()
for i in range(5):
    turtle.forward(100)
    turtle.right(144)
turtle.end_fill()

mygoto(-100,150)
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()

mygoto(-40,95)
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()

mygoto(-60,40)
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()

mygoto(-120,-10)
turtle.begin_fill()
for i in range(5):
    turtle.forward(50)
    turtle.right(144)
turtle.end_fill()
turtle.done()

stuNum='201709090028'
print('年级是:'+stuNum[0:4])
print('专业编号是:'+stuNum[4:9])
print('序号是:'+stuNum[-3:])

IDNO='440681199806140226'
print('性别是:'+IDNO[-2])
print('市区是:'+IDNO[0:6])
print('生日是:'+IDNO[6:14])

posted on 2018-05-16 21:46  梁梓蕙  阅读(247)  评论(0)    收藏  举报

导航