“ 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验证结果:
image3、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
网友评论