名称,性别,电话号设置随为变量:payload = "{"orgRoleCode":"20230601104000005756465300007420"," \ ""departmentCode":"20230605183700005731178700007705"," \ ""organizationCode":"20230601103800005727212400007418","employeeNo":"我改了已绑定的身份2","name":"孙伟伟5"," \ ""gender":"MALE","phone":"13028274945","credentialType":"passport"," \ ""credentialNo":"12343343"} "
时间: 2023-08-16 19:04:15 浏览: 80
如果您想将名称、性别、电话号码等参数值设置为随机变量,可以使用 Python 中的 random 模块生成随机的值,并将其赋给相应的参数。具体代码如下:
```python
import random
# 生成随机的姓名和性别
names = ['张三', '李四', '王五', '赵六', '钱七']
genders = ['MALE', 'FEMALE']
name = random.choice(names)
gender = random.choice(genders)
# 生成随机的电话号码
phone = str(random.randint(10000000000, 19999999999))
payload = '{"orgRoleCode":"20230601104000005756465300007420",' \
'"departmentCode":"20230605183700005731178700007705",' \
'"organizationCode":"20230601103800005727212400007418",' \
f'"employeeNo":"我改了已绑定的身份2",' \
f'"name":"{name}",' \
f'"gender":"{gender}",' \
f'"phone":"{phone}",' \
'"credentialType":"passport",' \
'"credentialNo":"12343343"}'
```
这样就可以生成随机的姓名、性别和电话号码,并将其赋值给相应的参数。
阅读全文