蟒蛇
import turtle
#长度,宽度,显示在屏幕的x和y,左上角开始
turtle.setup(650,500,(1080-650)/2,(1920-500)/2)
#将画笔提起,不画
turtle.penup()
#向前,我们的画笔一开始是不在那个位置的
turtle.fd(-250)
turtle.pendown()
#笔宽(半径吧,毕竟笔头是半圆)
turtle.pensize(25)
#设置颜色有三种方法
#1. 直接输入颜色
turtle.pencolor("black")
#2. 输入小数的颜色编码
turtle.pencolor(0,0,0)
#3. 输入大数编码
#!!!设置颜色编码为大数!!!
turtle.colormode(255)
#255,255,255为白色,0,0,0为黑色
turtle.pencolor(255,245,238) #目前为奶白->近似为255,255,255
turtle.pencolor(0,0,0)
#旋转绝对角度以屏幕横为x轴,竖为y轴做坐标系
turtle.seth(-40)
#旋转相对角度,即以海龟为自然坐标轴
#trutle.left(90) 左转90°
#循环4次
for i in range(4):
#第一个是半径,圆心在左侧r处,当r<0时就在右侧了,第二个是角度360度制
turtle.circle(40,80)
turtle.circle (-40,80)
turtle.circle(40,80/2)
turtle.fd(40)
turtle.circle(16,360)
turtle.fd(40*2/3)
#done()函数可以将窗口保持
#turtle.done() #我就不想在调试的时候放这个了
#引用turtle的另种方法 from <turtle> import 这样在用此库中的函数时可以直接使用,不用库+‘.’+函数名
#还有import<库名> as <库别名> 即改库的名字,在后面写时候简单调用(小名)
五角星
from turtle import*
import tkinter
win=tkinter.Tk()
System_Width=win.winfo_screenwidth()
System_Length=win.winfo_screenheight()
setup(650,500,(System_Width-650)/2,(System_Length-500)/2)
pencolor("black")
pensize(10)
seth(72)
r=100
for i in range(5):
fd(r)
right(144)
done()