日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python turtle怎么用变量_Python Turtle绘图指定变量时出现问题

發布時間:2025/4/17 python 123 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python turtle怎么用变量_Python Turtle绘图指定变量时出现问题 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

幾小時后我有一個作業要交,我不知道該做什么。

我使用的是python3。在

我一直試著運行代碼,但是我出錯了。在這一點上,我想我應該尋求幫助。在

提前謝謝你!在import turtle

import random

class myRectangle:

def __var__(self):

self.__x

self.__y

self.__width

self.__height

self.__color

def __init__(self, x, y, width, height, color):

self.__x = x

self.__y = y

self.__width = width

self.__height = height

self.__color = color

def getX(self):

return self.__x

def setX(self, x):

self.__x = x

def getY(self):

return self.__y

def setY(self, y):

self.__y = y

def getWidth(self):

return self.__width

def setWidth(self, width):

self.__width = width

def getHeight(self):

return self.__height

def setHeight(self, height):

self.__height = height

def getColor(self):

return self.__color

def setColor(self, color):

self.__color = color

def draw(self, turtle):

turtle.penup()

turtle.goto(self.getX(), self.getY())

turtle.heading(0)

turtle.pencolor("blue")

turtle.pendown()

turtle.begin_fill()

turtle.forward(self.__width())

turtle.left(90)

turtle.forward(self.__height())

turtle.left(90)

turtle.forward(self.__width())

turtle.left(90)

turtle.forward(self.__height())

turtle.left(90)

turtle.end_fill()

def main():

wn = turtle.TurtleScreen

mr = myRectangle

phil = turtle.Turtle()

macie = turtle.Turtle()

sashi = turtle.Turtle()

roxie = turtle.Turtle()

darla = turtle.Turtle()

sammy = turtle.Turtle()

phil.pencolor("blue")

phil.pensize(7)

listofcolors = ("blue", "red", "yellow", "orange", "pink", "green")

c = random.choice(listofcolors)

xy = random.randrange(-200, 201)

wh = random.randrange(1, 151)

for i in [phil, macie, sashi, roxie, darla, sammy]:

mr.setColor(c)

mr.setX(xy)

mr.setY(xy)

mr.setWidth(wh)

mr.setHeight(wh)

main()

錯誤:

^{pr2}$

總結

以上是生活随笔為你收集整理的python turtle怎么用变量_Python Turtle绘图指定变量时出现问题的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。