Faker python constructs virtual data

Source: Internet
Author: User

Python can use Faker to make some virtual data

Preferred Installation Faker

Pip Install Faker

The old version is called Faker-factory, but it doesn't apply.

Use Faker. Factory.create () to create and initialize the Faker generator (generator)

Here's how to use it:

From Faker import Factory
fake = Factory.create ()
# OR
From Faker Import Faker
fake = Faker ()
Fake.name ()
# ' Lucy cechtelar '
Fake.address ()
# "426 Jordy Lodge
# Cartwrightshire, SC 88120-6700 "
Fake.text ()

After each call to Faker, the returned data is not the same

In order to be able to return data in the first run and second run, you can use the seed ()

From Faker Import Faker
fake = Faker ()
Fake.seed (4321)
Print (Fake.name ()) runs multiple times, the results are the same, and the test is easy to use

Official website: Https://github.com/joke2k/faker can be viewed in more detail using

Faker python constructs virtual data

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.