python代码,只是生成随机颜色,未考虑其它。- import random
- s="0123456789abcdef"
- fg=random.sample(s,15) #先随机的不重复的 15个前景
- bg=(set(s)-set(fg)).pop() # 余下的一个作背景
- res=["{}{}".format(bg,i) for i in fg]
- print(res)
复制代码 随机结果:- ['5b', '56', '5f', '5d', '54', '5a', '53', '5c', '51', '50', '58', '57', '5e', '59', '52']
复制代码
|