import randomstr_ = '0'chars = 'ABCDEF0123456789'str_ += ''.join([random.choice(chars) for _ in range(31)])