如何在Python中生成随机HTML颜色?
如何在Python中生成随机HTML颜色(#ABABAB等)?我试着做一些类似的事情如何在Python中生成随机HTML颜色?,python,html,colors,Python,Html,Colors,如何在Python中生成随机HTML颜色(#ABABAB等)?我试着做一些类似的事情 random.choice('0','1','2',) 等等,但它不起作用。帮助谢谢。见 from random import choice def colour(): hex_chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'] randomColour = '#'
random.choice('0','1','2',)
等等,但它不起作用。帮助谢谢。见
from random import choice
def colour():
hex_chars = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f']
randomColour = '#'
for i in range(0, 6):
randomColour = randomColour + choice(hex_chars)
return randomColour