插入循环
""" 功能:五角星绘制,加入循环 """ import turtle def draw_pentagrm(size): count = 1 # 五角星绘制 while count <= 5: turtle.forward(size) turtle.right(144) count += 1 def main(): """ 主函数 """ turtle.penup() turtle.backward(200) turtle.pendown() turtle.pensize(2) turtle.pencolor('red') size = 50 while size <= 100: draw_pentagrm(size) size += 10 turtle.exitonclick() if __name__ == '__main__': main()