2023-10-07 15:24:29 +08:00
|
|
|
import random
|
|
|
|
import string
|
|
|
|
|
|
|
|
|
|
|
|
def get_random_num_code(length=8):
|
|
|
|
return "".join(random.choices(string.digits, k=length))
|
|
|
|
|
|
|
|
|
|
|
|
def get_random_letter_code(length=8):
|
|
|
|
return "".join(random.choices(string.ascii_lowercase, k=length))
|
|
|
|
|
|
|
|
|
|
|
|
def get_random_letter_and_num_code(length=4):
|
2023-10-16 16:59:52 +08:00
|
|
|
return ''.join(random.sample(string.ascii_letters + string.digits, length))
|