python颜色填充代码_在python tu中用颜色填充形状

我试着用颜色填充一个形状,但是当我运行它时,它不会显示出来。

我不应该用课堂来做这个吗?我不精通python-3,仍然在学习如何使用类import turtle

t=turtle.Turtle()

t.speed(0)

class Star(turtle.Turtle):

def __init__(self, x=0, y=0):

turtle.Turtle.__init__(self)

self.shape("")

self.color("")

#Creates the star shape

def shape(self, x=0, y=0):

self.fillcolor("red")

for i in range(9):

self.begin_fill()

self.left(90)

self.forward(90)

self.right(130)

self.forward(90)

self.end_fill()

#I was hoping this would fill the inside

def octagon(self, x=0.0, y=0.0):

turtle.Turtle.__init__(self)

def octa(self):

self.fillcolor("green")

self.begin_fill()

self.left(25)

for x in range(9):

self.forward(77)

self.right(40)

#doesn't run with out this

a=Star()

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值