Faker.py
2.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
#!/usr/bin/python
# -*- coding: UTF-8 -*-
import random
from faker import Factory
class random_data():
def __init__(self, type='zh_CN'):
self.type = type
self.fake = Factory().create(self.type)
def date(self):
"随机时间"
return self.fake.date(pattern="%Y-%m-%d")
def name(self):
"随机姓名"
return self.fake.name()
def identity_card(self):
"随机证件"
return self.fake.ssn(min_age=18, max_age=90)
def plate(self):
"随机车牌号"
return self.fake.license_plate()
def plate_cn(self,plate_len=6):
"随机车牌号"
char0='京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽赣粤青藏川宁琼'
char1='ABCDEFGHJKLMNPQRSTUVWXYZ'#车牌号中没有I和O,可自行百度
char2='1234567890'
len0=len(char0)-1
len1 = len(char1) - 1
len2 = len(char2) - 1
########
code = ''
index0 = random.randint(0,len0 )
index1 = random.randint(0,len1)
code += char0[index0]
code += char1[index1]
for i in range(0, plate_len-1):
index2 = random.randint(1, len2)
code += char2[index2]
return(code)
def country(self):
"随机国家代码"
return self.fake.country()
def province(self):
"随机省份"
return self.fake.province()
def city(self):
"随机城市"
return self.fake.city_suffix()
def district(self):
"随机街道"
return self.fake.district()
def address(self):
"随机地址全称"
return self.fake.address()
def phone_number(self):
"随机手机号"
return self.fake.phone_number()
def email(self):
"随机邮件"
return self.fake.email()
def longitude(self):
"随机经度"
return self.fake.longitude()
def latitude (self):
"随机维度"
return self.fake.latitude ()
def credit_card_number (self):
"随机卡号"
return self.fake.credit_card_number ()
# a=random_data()
# print(a.date())
# print(a.name())
# print(a.identity_card())
# print(a.plate())
# print(a.plate_cn(6))
# print(a.country())
# print(a.province())
# print(a.city())
# print(a.district())
# print(a.address())
# print(a.phone_number())
# print(a.email())
# print(a.longitude())
# print(a.latitude())
# print(a.credit_card_number())