我是编程新手,我必须做的一项任务是使用 for 循环和 .join 创建一个随机的十六进制颜色代码生成器。我下面的程序是否与您的操作方式接近,还是完全关闭?而且,有没有办法让随机数量的数字和字母出现在 6 以内?
import random
str = ("A","B","C","D","E","F","G","H")
seq = ("1","2","3","4","5","6", "7","8","9")
print '#',
for i in range(0,3):
letter = random.choice(str)
num = random.choice(seq)
print num.join(letter),
print letter.join(num)