-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy path1111.py
55 lines (53 loc) · 1.77 KB
/
1111.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
color = '1,2,3'
Colors = {'银色': [167, 169, 169], '皇家蓝': [225, 105, 65], '紫色': [128, 0, 128], '浅粉': [255, 182, 193], '深粉':[255, 20, 147]}
# print('qufan', Colors[color][::-1])
print(type(Colors['银色']))
# if isinstance(color, str):
# try:
# co = []
# for rgb in color.split(','):
# print("rgb", rgb)
# if rgb.startswith('0x' or '0X'):
# co.append(int(rgb, 16)) # 将16进制str转为10进制int整数
# else:
# co.append(int(rgb, 10)) # 将10进制str转为10进制int整数
# color = tuple(co)
# print(color)
# print(type(color))
# except:
# for key in Colors:
# if color == key:
# print( Colors[color][::-1])
# color = tuple(Colors[color][::-1])
# print(color)
# print(type(color))
# else:
# color = (1, 1, 1)
# print(color)
co = []
if color.startswith('0x' or '0X'):
for rgb in color.split(','):
co.append(int(rgb, 16)) # 将16进制str转为10进制int整数
color = tuple(co)
print(color)
print(type(color))
if color.startswith('0x' or '0X') :
try:
# co = []
for rgb in color.split(','):
co.append(int(rgb, 10)) # 将10进制str转为10进制int整数
color = tuple(co)
print(color)
print(type(color))
except:
for key in Colors:
if color == key:
# print(Colors[color][::-1])
color = Colors[color][::-1]
color = tuple(color)
print(color)
print(type(color))
# else:
# color = tuple(color)
# print(color)
# print(type(color))