What is the standard method for generating a nonce in Python?
问题 Can someone share the best practices for creating a nonce for an OAuth request in Python? 回答1: Here's how python-oauth2 does it: def generate_nonce(length=8): """Generate pseudorandom number.""" return ''.join([str(random.randint(0, 9)) for i in range(length)]) They also have: @classmethod def make_nonce(cls): """Generate pseudorandom number.""" return str(random.randint(0, 100000000)) Additionally there is this issue entitled: "make_nonce is not random enough", which proposes: def gen_nonce