热爱python,热爱生活,python需要浪漫,让我带大家走进浪漫的国度...写的不好的地方请大佬指教
import turtle
import time class Rose: def __init__(self):
self.interface() @classmethod
def interface(cls):
print('你喜欢玫瑰吗?')
lst = ['喜欢','不喜欢']
for index,hobby in enumerate (lst,1):
print(index,hobby)
while True:
try:
usr = int(input('请输入序号: ').strip())
if usr == 1:
print('你的选择是明智的')
cls.get_color()
break
else:
exit('再见')
except(ValueError,IndexError):
print('输入有误,请重新输入') @staticmethod
def get_rose(flower_color,leaf_color):
turtle.penup()
turtle.left(90)
turtle.fd(200)
turtle.pendown()
turtle.right(90)
turtle.fillcolor(flower_color)
turtle.begin_fill()
turtle.circle(10, 180)
turtle.circle(25, 110)
turtle.left(50)
turtle.circle(60, 45)
turtle.circle(20, 170)
turtle.right(24)
turtle.fd(30)
turtle.left(10)
turtle.circle(30, 110)
turtle.fd(20)
turtle.left(40)
turtle.circle(90, 70)
turtle.circle(30, 150)
turtle.right(30)
turtle.fd(15)
turtle.circle(80, 90)
turtle.left(15)
turtle.fd(45)
turtle.right(165)
turtle.fd(20)
turtle.left(155)
turtle.circle(150, 80)
turtle.left(50)
turtle.circle(150, 90)
turtle.end_fill()
turtle.left(150)
turtle.circle(-90, 70)
turtle.left(20)
turtle.circle(75, 105)
turtle.setheading(60)
turtle.circle(80, 98)
turtle.circle(-90, 40)
turtle.left(180)
turtle.circle(90, 40)
turtle.circle(-80, 98)
turtle.setheading(-83)
turtle.fd(30)
turtle.left(90)
turtle.fd(25)
turtle.left(45)
turtle.fillcolor(leaf_color)
turtle.begin_fill()
turtle.circle(-80, 90)
turtle.right(90)
turtle.circle(-80, 90)
turtle.end_fill()
turtle.right(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(85)
turtle.left(90)
turtle.fd(80)
turtle.right(90)
turtle.right(45)
turtle.fillcolor(leaf_color)
turtle.begin_fill()
turtle.circle(80, 90)
turtle.left(90)
turtle.circle(80, 90)
turtle.end_fill()
turtle.left(135)
turtle.fd(60)
turtle.left(180)
turtle.fd(60)
turtle.right(90)
turtle.circle(200, 60)
turtle.done() @staticmethod
def choose_color(color_table):
while True:
try:
for index, color in enumerate(color_table, 1):
print(index, color)
Silly_guy = int(input('请输入序号: ').strip())
break
except (ValueError, IndexError):
print('你输入的有误,请重新输入')
return color_table[Silly_guy - 1] @classmethod
def get_color(cls):
print('欢迎来到选花环节')
time.sleep(1)
print('那就先选择花花的颜色吧')
bingo = cls.flower()
print(f'好了花花的颜色是{bingo}')
time.sleep(1)
print('请选择叶子的颜色')
yoyo = cls.flower()
print(f'叶子的颜色是{yoyo}')
print('快去看看吧')
cls.get_rose(bingo,yoyo) @classmethod
def flower(cls):
Bekir = 'green|red|pink|black|purple|yellow|cyan'
color_table = Bekir.split('|')
ret = cls.choose_color(color_table)
return ret Rose()