class Color():
def __init__(self, color1, color2):
self.color1 = color1
self.color2 = color2
def Mixed(self):
Mixfinished = ''
if self.color1 in ['红色', '蓝色'] and self.color2 in ['红色', '蓝色'] and self.color2 != self.color1:
Mixfinished = '紫色'
elif self.color1 in ['红色', '黄色'] and self.color2 in ['红色', '黄色'] and self.color2 != self.color1:
Mixfinished = '橙色'
elif self.color1 in ['蓝色', '黄色'] and self.color2 in ['蓝色', '黄色'] and self.color2 != self.color1:
Mixfinished = '绿色'
else:
Mixfinished = '混合后颜色未知!'
print(Mixfinished)
judge = 'T'
while judge == 'T':
color1 = input('请输入第一种颜色:')
color2 = input('请输入第二种颜色:')
if color1 in ['红色','黄色','蓝色'] and color2 in ['红色','黄色','蓝色']:
C = Color(color1, color2)
C.Mixed()
judge = input('想要继续输入吗?T:继续输入\F:退出')
else:
print('输入的颜色不符合标准!')
exit(-1)
有啥需要改的可以继续问