python生成随机数据工具类

import random
import numpy as np
import time
from faker import Faker


def get_many_int_num():
    list1 = np.random.randint(10, 99999, 5)
    return list1.tolist()


def get_many_num(low_num, high_num, size):
    list1 = np.random.uniform(low_num, high_num, size)
    return list1.tolist()


# 随机生成0.1-0.9数据
def radio():
    return format(random.uniform(0.1, 0.9), '0.1f')


# 随机获取列表元素
def get_list_tuple(new_list):
    return random.choice(new_list)


# 随机生成中文句子
def get_str():
    fake = Faker(locale='zh_CN')
    return fake.sentence()


# 随机生成中文段落
def get_text():
    fake = Faker(locale='zh_CN')
    return fake.text()


# 随机生成中文词语
def get_word():
    fake = Faker(locale='zh_CN')
    return fake.word()


def get_mobile():
    mobiles = ['130', '131', '132', '133', '134', '135', '136', '137', '138', '139', '196', '198', '176', '177',
               '150', '151', '152', '155', '156', '157', '158', '159', '147', '181', '188', '189', '166']
    numbers = str(int(time.time()))[2:]
    print(numbers)
    mobile = random.choice(mobiles) + numbers
    return mobile


def get_bank_no(name):
    bank = []
    if name == '建设银行':
        for i in range(6227007201360040000, 6227007201360049999, 1):
            bank.append(i)
        return random.choice(bank)

    if name == '招商银行':
        for i in range(6215593700010000, 6215593700019999, 1):
            bank.append(i)
        return random.choice(bank)

    if name == '工商银行':
        for i in range(6212261001080770000, 6212261001080799999, 1):
            bank.append(i)
        return random.choice(bank)

    if name == '中国银行':
        for i in range(6217856200015160000, 6217856200015169999, 1):
            bank.append(i)
        return random.choice(bank)

你可能感兴趣的:(接口自动化系列,python,开发语言,numpy)