Python练习

from turtle import *
from time import *

setup(600,400,0,0)
bgcolor('red')
color('yellow')
fillcolor('yellow')

def mygoto(x,y):
    up()
    goto(x,y)
    down()

def drawu(l):
    begin_fill()
    for i in range(5):
        forward(l)
        right(144)
    end_fill()


mygoto(-230,85)
drawu(100)

for i in range(4):
    x=1
    if i in[0,3]:
        x=0
    mygoto(-100+x*40,150-i*45)
    left(25-i*15)
    drawu(30)

mygoto(0,0)
hideturtle()
done()

  

国旗如上:

str = '''– Look, I was gonna go easy on you not to hurt your feelings
– But I'm only to get this one chance
– Something's wrong, I can feel it (Six minutes, Slim Shady, you're on)
– Just a feeling, like something's about to happen, but I don't know what
It's a fatal mistake if you think I need to be overseas and take a vacation to tip a broad
And make a [?] on the face and don't be a retard
Be a king? Think not - why be a king when you can be a God?'''


new_str=str.split()
i=1
for c in new_str:
    if i < 5:
        print(c)
    elif i % 5 == 0:
        print("c
")
    else:
        print(c)
    i=i+1

  对歌词进行分开成功,替换失败

原文地址:https://www.cnblogs.com/phoenlix/p/8619552.html