python3环境搭建及绘图

python3来了,您准备好了吗?

01

安装python3

https://www.python.org/downloads/

选择python3.7版本

image

双击安装

安装成功后配置python的环境变量

image

新建系统变量PATH_HOME,变量值配置为python.exe所在路径,配置完成后再Path末尾添加;%PYTHON_HOME%;%PYTHON_HOME%\Scripts

打开cmd命令行,输入python --version查看

image

证明python已经安装成功了

02

安装开发ide

这里推荐pycharm作为开发ide,下载地址:http://www.jetbrains.com/pycharm/download/#section=windows

安装完成后,新建python工程

image
image

创建完python工程后,来实现第一个python程序 hello testerbang

实例:

image

查看运行结果,右键选择Run "hello_testerbang"

image

验证结果:

image

3、practise:用python3自带的turtle类库画测试邦标志

image

实例代码:

import turtle

"""

使用python3的turtle库绘制testerbang标志

"""

turtle.color('#05CDFF')

turtle.pensize(20)

turtle.circle(100)

turtle.penup()

turtle.goto(-60, 150)

turtle.pendown()

turtle.begin_fill()

turtle.fillcolor('#05CDFF')

for i in range(1, 5):

if i % 2 == 1:

    n = 120

elif i % 2 == 0:

    n = 30

turtle.forward(n)

turtle.right(90)

turtle.end_fill()

turtle.penup()

turtle.goto(-15, 130)

turtle.pendown()

turtle.begin_fill()

turtle.fillcolor('#05CDFF')

for i in range(1, 5):

if i % 2 == 1:

    n = 30

elif i % 2 == 0:

    n = 100

turtle.forward(n)

turtle.right(90)

turtle.end_fill()

turtle.penup()

turtle.goto(-30, 125)

turtle.pendown()

turtle.begin_fill()

turtle.fillcolor('#FFFFFF')

turtle.pensize(1)

turtle.circle(10)

turtle.end_fill()

turtle.penup()

turtle.goto(30, 125)

turtle.pendown()

turtle.begin_fill()

turtle.fillcolor('#FFFFFF')

turtle.pensize(1)

turtle.circle(10)

turtle.end_fill()

t= turtle.Turtle()

t.penup()

t.goto(-50, -55)

t.pendown()

t.write("测试帮", font=("微软雅黑", 28, "normal")) #fonttype有normal, bold, italic, underline

t.penup()

t.goto(-90, -85)

t.pendown()

t.write("专注测试技术推广落地", font=("Arial", 14, "bold")) #fonttype可以自由组合,如"bold italic"

turtle.done()

运行结果:

image
image
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • 个人学习批处理的初衷来源于实际工作;在某个迭代版本有个BS(安卓手游模拟器)大需求,从而在测试过程中就重复涉及到...
    Luckykailiu阅读 10,306评论 0 11
  • Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一个小乌龟,在一个横轴为x、纵轴为y的坐标系原...
    yeszao阅读 8,253评论 1 5
  • # !/usr/bin/env python3 # -*- coding: utf-8 -*- # @Author...
    风中追风_3e95阅读 1,558评论 0 0
  • ▲深圳夜景,从莲花山看,胡子状为会展中心 图片来源:easyvoyage.co.uk 如果你想了解深圳,没必要百度...
    富链Linda阅读 3,064评论 0 0
  • 有些事情,冥冥中是可以感知的,我一直都觉得自己第六感准得爆棚。当真相摊在眼前的时候,虽不至于血淋淋,但是心情真的飓...
    浅浅的柒阅读 1,508评论 0 0

友情链接更多精彩内容