Use python's faker library to generate simple fake information for testing

        This chapter uses the faker library to generate fake information, which can be used for various tests. First install the faker library, press win+R on the window system to open the cmd window, and enter pip install faker. If the following prompt appears, the installation is successful.

Figure 1 successfully installed the faker library

1. f.name() output name

import faker
f = faker.Faker('zh_CN')

name = f.name()
print(name)
Figure 2 Generating fake names

 

 2. f.phone_number() outputs a fake phone number

phone = f.phone_number()
print(phone)
Figure 3 Generating a fake phone number

 3. f.job() generates a fake job

job = f.job()
print(job)
Figure 4 Generating fake jobs

 4. f.address() generates a fake address

address = f.address()
print(address)

 

Figure 5 Generating a fake address

Guess you like

Origin blog.csdn.net/m0_71559726/article/details/130178167