python3来了,您准备好了吗?

 

 

01

安装python3

 

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

选择python3.7版本

python3环境搭建及绘图

双击安装

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

python3环境搭建及绘图

 

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

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

 

python3环境搭建及绘图

证明python已经安装成功了

 

02

 

  安装开发ide

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

安装完成后,新建python工程

python3环境搭建及绘图

python3环境搭建及绘图

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

实例:

python3环境搭建及绘图

 

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

python3环境搭建及绘图

验证结果:

python3环境搭建及绘图

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

python3环境搭建及绘图

实例代码:

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()

运行结果:

python3环境搭建及绘图

 

python3环境搭建及绘图

相关文章:

  • 2021-12-09
  • 2021-04-15
  • 2021-12-07
  • 2021-12-18
  • 2021-08-22
  • 2021-08-07
  • 2021-12-07
  • 2021-08-29
猜你喜欢
  • 2021-05-01
  • 2022-02-09
  • 2022-02-09
  • 2021-06-30
相关资源
相似解决方案