log:

在mock数据或者性能测试过程中,需要对一些参数进行动态传递,可以使用以下方法对部分参数进行操作:

# !/usr/bin/env python
# -*- encoding: utf-8 -*-
# @Author : yyq

account = ["interface_sequence_1", "interface_sequence_2", "interface_sequence_3", "interface_sequence_4",
           "interface_sequence_5", "interface_sequence_6", "interface_sequence_7", "interface_sequence_8",
           "interface_sequence_9", "interface_sequence_10"]


import random

# 随机返回一个列表元素,account代表list,1代表获取元素个数
print(random.sample(account,1))

结果举例:['interface_sequence_6']

# 随机返回一个元素内容
print(random.choice(account))

结果举例:interface_sequence_6

 

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐