python实现画五角星和螺旋线的示例

yipeiwu_com6年前Python基础

如下所示:

# -*- coding:UTF-8 -*-
__author__ = "zhangguodong"
__time__ = "2017.11.16"
 
import turtle
 
turtle.title("张国栋画五角星")
turtle.setup(500,300,0,0)
turtle.fillcolor("red")
turtle.begin_fill()
 
while True:
  turtle.forward(220)
  turtle.right(144)
  if abs(turtle.pos()) < 1:
      break
 
turtle.end_fill()
turtle.done()

python 画五角星和螺旋线

# -*- coding:UTF-8 -*-
__author__ = "zhangguodong"
__time__ = "2017.11.17"
 
import turtle
 
turtle.title("张国栋绘制螺旋线")
turtle.setup(400,400,0,0)
turtle.speed(10)  ###设置绘制时的速度
turtle.pensize(2)  ###设置画笔尺寸
 
for x in range(100):
  turtle.forward(2*x)
  turtle.left(90)
 
turtle.done()

python 画五角星和螺旋线

以上这篇python实现画五角星和螺旋线的示例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持【听图阁-专注于Python设计】。

相关文章

详解python读取image

python 读取image 在python中我们有两个库可以处理图像文件,scipy和matplotlib. 安装库 pip install matplotlib pillow s...

python使用paramiko模块实现ssh远程登陆上传文件并执行

程序执行时需要读取两个文件command.txt和ipandpass.txt。格式如下: 复制代码 代码如下:command.txt:ThreadNum:1port:22local_di...

Python实现字符串反转的常用方法分析【4种方法】

本文实例讲述了Python实现字符串反转的常用方法。分享给大家供大家参考,具体如下: 下面是实现python字符串反转的四种方法: 1. 切片 def rev(s): return...

python 产生token及token验证的方法

1、前言 最近在做微信公众号开发在进行网页授权时,微信需要用户自己在授权url中带上一个类似token的state的参数,以防止跨站攻击。 在经过再三思考之后,自己试着实现一个产生tok...

详解Python2.x中对Unicode编码的使用

我确定有很多关于Unicode和Python的说明,但为了方便自己的理解使用,我还是打算再写一些关于它们的东西。   字节流 vs Unicode对象 我们先来用Python定...