from faker import Faker
from random import randint
f = Faker()
data = {'name': 'Barry Long', 'email': 'tammy28@example.com', 'age': 20}
# Generate data from this
def Generate_like_this(data : dict, f : Faker):
result = {}
funcs = {
'name': f.name,
'email': f.email
}
for k in data:
if k in funcs:
result[k] = funcs[k]()
if isinstance(data[k], int):
result[k] = randint(1, data[k])
return result
print(Generate_like_this(data = data, f = Faker()))
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter