person.py 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. """
  2. @ Author: Mr.Hat
  3. @ Date: 2024/3/30 14:05
  4. @ Description:
  5. @ History:
  6. """
  7. import random
  8. import string
  9. import names
  10. from random_words import RandomNicknames # pip install RandomWords
  11. class Person:
  12. def __init__(self):
  13. self.username = RandomNicknames().random_nick(gender=random.choice(['f', 'm'])).lower() + \
  14. Person.random_string_old(3) + str(random.randint(1, 9))
  15. self.first_name, self.last_name = names.get_full_name().split(" ")
  16. @staticmethod
  17. def random_string_old(length, chars=string.ascii_lowercase):
  18. return ''.join(random.choice(chars) for _ in range(length))
  19. @staticmethod
  20. def random_string(length=8, chars=string.ascii_lowercase):
  21. return ''.join(random.choice(chars) for _ in range(length)) + random.choice(string.digits) + random.choice(
  22. string.ascii_uppercase) + random.choice(['.', '@', '!', "$"])
  23. def generate_email(self):
  24. return f"{self.username[:-random.choice(range(1, 3))].lower()}@{random.choice(['gmail.com', 'outlook.com', 'yahoo.com'])}"