You can download this code by clicking the button below.
This code is now available for download.
代码含义解释[英文]
Technology Stack : 代码所使用到的包和技术栈[英文]
Code Type : The type of code
Code Difficulty :
import random
def random_string(length=10):
"""Generate a random string of a given length."""
letters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
return ''.join(random.choice(letters) for i in range(length))
def random_email():
"""Generate a random email address."""
domains = ['gmail.com', 'yahoo.com', 'hotmail.com', 'outlook.com']
return random_string(5) + '@' + random.choice(domains)
def random_phone_number():
"""Generate a random phone number."""
return random.randint(1000000000, 9999999999)
def random_user_data():
"""Generate random user data."""
user_data = {
"name": random_string(10),
"email": random_email(),
"phone": random_phone_number(),
"age": random.randint(18, 70)
}
return user_data