擅长:python、mysql、java
<p>或者做下面的,有另一种风格的颜色:</p>
<pre><code>for x in range(NUM_LINES):
color = colors[x//25]
turtle.left(90)
turtle.forward(2+(4*x))
turtle.pencolor(color)
</code></pre>
<hr/>
<pre><code>import turtle
colors = ["blue", "red", "yellow", "pink"]
NUM_LINES = 100
turtle.hideturtle()
turtle.speed(0)
colors = ["blue", "red", "yellow", "pink"]
for x in range(NUM_LINES):
color = colors[x//25]
turtle.left(90)
turtle.forward(2+(4*x))
turtle.pencolor(color)
</code></pre>
<p>输出过程结束:</p>
<p><a href="https://i.stack.imgur.com/CJmye.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CJmye.png" alt="enter image description here"/></a></p>