Home > Article > Backend Development > Python method to generate random numbers with any range and any precision
The following is a Python method for generating random numbers with any range and any precision. It has certain reference value and I hope it will be helpful to everyone.
An example is as follows:
# -*- coding: utf-8 -*- import numpy as np random = np.random.RandomState(0)#RandomState生成随机数种子 for i in range(200):#随机数个数 a = random.uniform(-0.1, 0.1)#随机数范围 print round(a, 2)#随机数精度要求
The above is the detailed content of Python method to generate random numbers with any range and any precision. For more information, please follow other related articles on the PHP Chinese website!