Faker Library-Based User Profile Generation

  • Share this:

Code introduction


This function uses the Faker library to generate a user profile containing name, email, phone number, and address.


Technology Stack : Faker

Code Type : Python Function

Code Difficulty : Intermediate


                
                    
from faker import Faker
import random

def generate_user_profile():
    fake = Faker()
    user_name = fake.name()
    user_email = fake.email()
    user_phone = fake.phone_number()
    user_address = fake.address()

    return {
        "name": user_name,
        "email": user_email,
        "phone": user_phone,
        "address": user_address
    }

# JSON Explanation                
              
Tags: