加证件类型,证件号:def generate_data(add_user): # 学/工号 id_num = random.randint(100000, 999999) # 姓名 first_names = ['张', '王', '李', '刘', '赵', '陈', '周', '钱', "孙", "吴", "曾", "冯", "陶", "将", "黄", "胡", "朱", "杨", "江", "何"] s_names = ['云', '风', '山', '河', '林', '羽', '行', "雪", '月', '雨', '冰', '雷', '鞥', '时', '文', '代', '格', '台', "发", '方', '欧', '白'] l_names = ['雷', '鞥', '时', '文', '代', '格', '台', "发", '方', '欧', '白'] name = random.choice(first_names) + random.choice(s_names) + random.choice(l_names) # 性别 gender = random.choice(['男', '女']) # 身份 identity = random.choice(["学生"]) # 部门 department = random.choice( ["20230608094700005793941100036910"]) # 手机号 phone_num = '1' + str(random.randint(3, 9)) + ''.join(str(random.randint(0, 9)) for _ in range(9)) if add_user: return [id_num, name, gender, identity, department, phone_num] else: return
时间: 2023-08-20 21:48:55 浏览: 67
好的,我来帮您修改一下:
```python
import random
def generate_data(add_user):
# 学/工号
id_num = random.randint(100000, 999999)
# 姓名
first_names = ['张', '王', '李', '刘', '赵', '陈', '周', '钱', "孙", "吴", "曾", "冯", "陶", "将", "黄", "胡", "朱", "杨", "江", "何"]
s_names = ['云', '风', '山', '河', '林', '羽', '行', "雪", '月', '雨', '冰', '雷', '鞥', '时', '文', '代', '格', '台', "发", '方', '欧', '白']
l_names = ['雷', '鞥', '时', '文', '代', '格', '台', "发", '方', '欧', '白']
name = random.choice(first_names) + random.choice(s_names) + random.choice(l_names)
# 性别
gender = random.choice(['男', '女'])
# 证件类型
id_type = random.choice(["身份证", "护照", "驾驶证"])
# 证件号
id_number = ''.join(str(random.randint(0, 9)) for _ in range(18)) if id_type == "身份证" else ''.join(str(random.randint(0, 9)) for _ in range(9))
# 身份
identity = random.choice(["学生"])
# 部门
department = random.choice(["20230608094700005793941100036910"])
# 手机号
phone_num = '1' + str(random.randint(3, 9)) + ''.join(str(random.randint(0, 9)) for _ in range(9))
if add_user:
return [id_num, name, gender, id_type, id_number, identity, department, phone_num]
else:
return
```
其中,我添加了 `id_type` 和 `id_number` 两个变量用于生成证件类型和证件号,并将它们添加到了返回的列表中,以便您使用。
相关推荐
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)