我想更改列表,使其连续两次具有相同的值



我想更改列表,使其连续两次具有相同的值。正如您在下面看到的,RGB值中当前没有覆盖范围。我希望有两个相同的连续RGB值,但我不知道怎么做。如果你能告诉我怎么做,我将不胜感激。

import seaborn as sns
def get_colorpalette(colorpalette, file_number):
palette = sns.color_palette(
colorpalette, file_number)
rgb = ['rgb({},{},{})'.format(*[x*256 for x in rgb])
for rgb in palette]
return rgb
['rgb(220.16,95.0272,87.03999999999999)',
'rgb(220.16,167.6381090909091,87.03999999999999)',
'rgb(200.0709818181818,220.16,87.03999999999999)',
'rgb(127.46007272727276,220.16,87.03999999999999)',
'rgb(87.03999999999999,220.16,119.23083636363639)',
・
・
・
['rgb(220.16,95.0272,87.03999999999999)',
'rgb(220.16,95.0272,87.03999999999999)',
'rgb(220.16,167.6381090909091,87.03999999999999)',
'rgb(220.16,167.6381090909091,87.03999999999999)',
'rgb(200.0709818181818,220.16,87.03999999999999)',
'rgb(200.0709818181818,220.16,87.03999999999999)',
・
・
・

使用for循环可以轻松完成。我使用了字符作为元素,因为最终列表中的元素也是字符串。

a = ['a', 'b', 'c']
aa = []
for i in a:
aa.append(i)
aa.append(i)
aa
['a', 'a', 'b', 'b', 'c', 'c']

最新更新