radom
radom模块提供了随机生成对象的方法
Help on module random: NAME
random - Random variable generators. FILE
/usr/local/lib/python2.7/random.py MODULE DOCS
http://docs.python.org/library/random DESCRIPTION
integers
--------
uniform within range sequences
---------
pick random element
pick random sample
generate random permutation distributions on the real line:
------------------------------
uniform
triangular
normal (Gaussian)
lognormal
negative exponential
gamma
beta
pareto
Weibull distributions on the circle (angles 0 to 2pi)
---------------------------------------------
circular uniform
von Mises General notes on the underlying Mersenne Twister core generator: * The period is 2**19937-1.
* It is one of the most extensively tested generators in existence.
* Without a direct way to compute N steps forward, the semantics of
jumpahead(n) are weakened to simply jump to another distant state and rely
on the large period to avoid overlapping sequences.
* The random() method is implemented in C, executes in a single Python step,
and is, therefore, threadsafe. CLASSES
_random.Random(__builtin__.object)
Random
SystemRandom
WichmannHill class Random(_random.Random)
| Random number generator base class used by bound module functions.
|
| Used to instantiate instances of Random to get generators that don't
| share state. Especially useful for multi-threaded programs, creating
| a different instance of Random for each thread, and using the jumpahead()
| method to ensure that the generated sequences seen by each thread don't
| overlap.
|
| Class Random can also be subclassed if you want to use a different basic
| generator of your own devising: in that case, override the following
| methods: random(), seed(), getstate(), setstate() and jumpahead().
| Optionally, implement a getrandbits() method so that randrange() can cover
| arbitrarily large ranges.
|
| Method resolution order:
| Random
| _random.Random
| __builtin__.object
|
| Methods defined here:
|
| __getstate__(self)
|
| __init__(self, x=None)
| Initialize an instance.
|
| Optional argument x controls seeding, as for Random.seed().
|
| __reduce__(self)
|
| __setstate__(self, state)
|
| betavariate(self, alpha, beta)
| Beta distribution.
|
| Conditions on the parameters are alpha > 0 and beta > 0.
| Returned values range between 0 and 1.
|
| choice(self, seq)
| Choose a random element from a non-empty sequence.
|
| expovariate(self, lambd)
| Exponential distribution.
|
| lambd is 1.0 divided by the desired mean. It should be
| nonzero. (The parameter would be called "lambda", but that is
| a reserved word in Python.) Returned values range from 0 to
| positive infinity if lambd is positive, and from negative
| infinity to 0 if lambd is negative.
|
| gammavariate(self, alpha, beta)
| Gamma distribution. Not the gamma function!
|
| Conditions on the parameters are alpha > 0 and beta > 0.
|
| The probability distribution function is:
|
| x ** (alpha - 1) * math.exp(-x / beta)
| pdf(x) = --------------------------------------
| math.gamma(alpha) * beta ** alpha
|
| gauss(self, mu, sigma)
| Gaussian distribution.
|
| mu is the mean, and sigma is the standard deviation. This is
| slightly faster than the normalvariate() function.
|
| Not thread-safe without a lock around calls.
|
| getstate(self)
| Return internal state; can be passed to setstate() later.
|
| jumpahead(self, n)
| Change the internal state to one that is likely far away
| from the current state. This method will not be in Py3.x,
| so it is better to simply reseed.
|
| lognormvariate(self, mu, sigma)
| Log normal distribution.
|
| If you take the natural logarithm of this distribution, you'll get a
| normal distribution with mean mu and standard deviation sigma.
| mu can have any value, and sigma must be greater than zero.
|
| normalvariate(self, mu, sigma)
| Normal distribution.
|
| mu is the mean, and sigma is the standard deviation.
|
| paretovariate(self, alpha)
| Pareto distribution. alpha is the shape parameter.
|
| randint(self, a, b)
| Return random integer in range [a, b], including both end points.
|
| randrange(self, start, stop=None, step=1, _int=<type 'int'>, _maxwidth=9007199254740992L)
| Choose a random item from range(start, stop[, step]).
|
| This fixes the problem with randint() which includes the
| endpoint; in Python this is usually not what you want.
|
| sample(self, population, k)
| Chooses k unique random elements from a population sequence.
|
| Returns a new list containing elements from the population while
| leaving the original population unchanged. The resulting list is
| in selection order so that all sub-slices will also be valid random
| samples. This allows raffle winners (the sample) to be partitioned
| into grand prize and second place winners (the subslices).
|
| Members of the population need not be hashable or unique. If the
| population contains repeats, then each occurrence is a possible
| selection in the sample.
|
| To choose a sample in a range of integers, use xrange as an argument.
| This is especially fast and space efficient for sampling from a
| large population: sample(xrange(10000000), 60)
|
| seed(self, a=None)
| Initialize internal state from hashable object.
|
| None or no argument seeds from current time or from an operating
| system specific randomness source if available.
|
| If a is not None or an int or long, hash(a) is used instead.
|
| setstate(self, state)
| Restore internal state from object returned by getstate().
|
| shuffle(self, x, random=None)
| x, random=random.random -> shuffle list x in place; return None.
|
| Optional arg random is a 0-argument function returning a random
| float in [0.0, 1.0); by default, the standard random.random.
|
| triangular(self, low=0.0, high=1.0, mode=None)
| Triangular distribution.
|
| Continuous distribution bounded by given lower and upper limits,
| and having a given mode value in-between.
|
| http://en.wikipedia.org/wiki/Triangular_distribution
|
| uniform(self, a, b)
| Get a random number in the range [a, b) or [a, b] depending on rounding.
|
| vonmisesvariate(self, mu, kappa)
| Circular data distribution.
|
| mu is the mean angle, expressed in radians between 0 and 2*pi, and
| kappa is the concentration parameter, which must be greater than or
| equal to zero. If kappa is equal to zero, this distribution reduces
| to a uniform random angle over the range 0 to 2*pi.
|
| weibullvariate(self, alpha, beta)
| Weibull distribution.
|
| alpha is the scale parameter and beta is the shape parameter.
|
| ----------------------------------------------------------------------
| Data descriptors defined here:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| VERSION = 3
|
| ----------------------------------------------------------------------
| Methods inherited from _random.Random:
|
| __getattribute__(...)
| x.__getattribute__('name') <==> x.name
|
| getrandbits(...)
| getrandbits(k) -> x. Generates a long int with k random bits.
|
| random(...)
| random() -> x in the interval [0, 1).
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from _random.Random:
|
| __new__ = <built-in method __new__ of type object>
| T.__new__(S, ...) -> a new object with type S, a subtype of T class SystemRandom(Random)
| Alternate random number generator using sources provided
| by the operating system (such as /dev/urandom on Unix or
| CryptGenRandom on Windows).
|
| Not available on all systems (see os.urandom() for details).
|
| Method resolution order:
| SystemRandom
| Random
| _random.Random
| __builtin__.object
|
| Methods defined here:
|
| getrandbits(self, k)
| getrandbits(k) -> x. Generates a long int with k random bits.
|
| getstate = _notimplemented(self, *args, **kwds)
|
| jumpahead = _stub(self, *args, **kwds)
|
| random(self)
| Get the next random number in the range [0.0, 1.0).
|
| seed = _stub(self, *args, **kwds)
|
| setstate = _notimplemented(self, *args, **kwds)
|
| ----------------------------------------------------------------------
| Methods inherited from Random:
|
| __getstate__(self)
|
| __init__(self, x=None)
| Initialize an instance.
|
| Optional argument x controls seeding, as for Random.seed().
|
| __reduce__(self)
|
| __setstate__(self, state)
|
| betavariate(self, alpha, beta)
| Beta distribution.
|
| Conditions on the parameters are alpha > 0 and beta > 0.
| Returned values range between 0 and 1.
|
| choice(self, seq)
| Choose a random element from a non-empty sequence.
|
| expovariate(self, lambd)
| Exponential distribution.
|
| lambd is 1.0 divided by the desired mean. It should be
| nonzero. (The parameter would be called "lambda", but that is
| a reserved word in Python.) Returned values range from 0 to
| positive infinity if lambd is positive, and from negative
| infinity to 0 if lambd is negative.
|
| gammavariate(self, alpha, beta)
| Gamma distribution. Not the gamma function!
|
| Conditions on the parameters are alpha > 0 and beta > 0.
|
| The probability distribution function is:
|
| x ** (alpha - 1) * math.exp(-x / beta)
| pdf(x) = --------------------------------------
| math.gamma(alpha) * beta ** alpha
|
| gauss(self, mu, sigma)
| Gaussian distribution.
|
| mu is the mean, and sigma is the standard deviation. This is
| slightly faster than the normalvariate() function.
|
| Not thread-safe without a lock around calls.
|
| lognormvariate(self, mu, sigma)
| Log normal distribution.
|
| If you take the natural logarithm of this distribution, you'll get a
| normal distribution with mean mu and standard deviation sigma.
| mu can have any value, and sigma must be greater than zero.
|
| normalvariate(self, mu, sigma)
| Normal distribution.
|
| mu is the mean, and sigma is the standard deviation.
|
| paretovariate(self, alpha)
| Pareto distribution. alpha is the shape parameter.
|
| randint(self, a, b)
| Return random integer in range [a, b], including both end points.
|
| randrange(self, start, stop=None, step=1, _int=<type 'int'>, _maxwidth=9007199254740992L)
| Choose a random item from range(start, stop[, step]).
|
| This fixes the problem with randint() which includes the
| endpoint; in Python this is usually not what you want.
|
| sample(self, population, k)
| Chooses k unique random elements from a population sequence.
|
| Returns a new list containing elements from the population while
| leaving the original population unchanged. The resulting list is
| in selection order so that all sub-slices will also be valid random
| samples. This allows raffle winners (the sample) to be partitioned
| into grand prize and second place winners (the subslices).
|
| Members of the population need not be hashable or unique. If the
| population contains repeats, then each occurrence is a possible
| selection in the sample.
|
| To choose a sample in a range of integers, use xrange as an argument.
| This is especially fast and space efficient for sampling from a
| large population: sample(xrange(10000000), 60)
|
| shuffle(self, x, random=None)
| x, random=random.random -> shuffle list x in place; return None.
|
| Optional arg random is a 0-argument function returning a random
| float in [0.0, 1.0); by default, the standard random.random.
|
| triangular(self, low=0.0, high=1.0, mode=None)
| Triangular distribution.
|
| Continuous distribution bounded by given lower and upper limits,
| and having a given mode value in-between.
|
| http://en.wikipedia.org/wiki/Triangular_distribution
|
| uniform(self, a, b)
| Get a random number in the range [a, b) or [a, b] depending on rounding.
|
| vonmisesvariate(self, mu, kappa)
| Circular data distribution.
|
| mu is the mean angle, expressed in radians between 0 and 2*pi, and
| kappa is the concentration parameter, which must be greater than or
| equal to zero. If kappa is equal to zero, this distribution reduces
| to a uniform random angle over the range 0 to 2*pi.
|
| weibullvariate(self, alpha, beta)
| Weibull distribution.
|
| alpha is the scale parameter and beta is the shape parameter.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Random:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from Random:
|
| VERSION = 3
|
| ----------------------------------------------------------------------
| Methods inherited from _random.Random:
|
| __getattribute__(...)
| x.__getattribute__('name') <==> x.name
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from _random.Random:
|
| __new__ = <built-in method __new__ of type object>
| T.__new__(S, ...) -> a new object with type S, a subtype of T class WichmannHill(Random)
| Method resolution order:
| WichmannHill
| Random
| _random.Random
| __builtin__.object
|
| Methods defined here:
|
| getstate(self)
| Return internal state; can be passed to setstate() later.
|
| jumpahead(self, n)
| Act as if n calls to random() were made, but quickly.
|
| n is an int, greater than or equal to 0.
|
| Example use: If you have 2 threads and know that each will
| consume no more than a million random numbers, create two Random
| objects r1 and r2, then do
| r2.setstate(r1.getstate())
| r2.jumpahead(1000000)
| Then r1 and r2 will use guaranteed-disjoint segments of the full
| period.
|
| random(self)
| Get the next random number in the range [0.0, 1.0).
|
| seed(self, a=None)
| Initialize internal state from hashable object.
|
| None or no argument seeds from current time or from an operating
| system specific randomness source if available.
|
| If a is not None or an int or long, hash(a) is used instead.
|
| If a is an int or long, a is used directly. Distinct values between
| 0 and 27814431486575L inclusive are guaranteed to yield distinct
| internal states (this guarantee is specific to the default
| Wichmann-Hill generator).
|
| setstate(self, state)
| Restore internal state from object returned by getstate().
|
| whseed(self, a=None)
| Seed from hashable object's hash code.
|
| None or no argument seeds from current time. It is not guaranteed
| that objects with distinct hash codes lead to distinct internal
| states.
|
| This is obsolete, provided for compatibility with the seed routine
| used prior to Python 2.1. Use the .seed() method instead.
|
| ----------------------------------------------------------------------
| Data and other attributes defined here:
|
| VERSION = 1
|
| ----------------------------------------------------------------------
| Methods inherited from Random:
|
| __getstate__(self)
|
| __init__(self, x=None)
| Initialize an instance.
|
| Optional argument x controls seeding, as for Random.seed().
|
| __reduce__(self)
|
| __setstate__(self, state)
|
| betavariate(self, alpha, beta)
| Beta distribution.
|
| Conditions on the parameters are alpha > 0 and beta > 0.
| Returned values range between 0 and 1.
|
| choice(self, seq)
| Choose a random element from a non-empty sequence.
|
| expovariate(self, lambd)
| Exponential distribution.
|
| lambd is 1.0 divided by the desired mean. It should be
| nonzero. (The parameter would be called "lambda", but that is
| a reserved word in Python.) Returned values range from 0 to
| positive infinity if lambd is positive, and from negative
| infinity to 0 if lambd is negative.
|
| gammavariate(self, alpha, beta)
| Gamma distribution. Not the gamma function!
|
| Conditions on the parameters are alpha > 0 and beta > 0.
|
| The probability distribution function is:
|
| x ** (alpha - 1) * math.exp(-x / beta)
| pdf(x) = --------------------------------------
| math.gamma(alpha) * beta ** alpha
|
| gauss(self, mu, sigma)
| Gaussian distribution.
|
| mu is the mean, and sigma is the standard deviation. This is
| slightly faster than the normalvariate() function.
|
| Not thread-safe without a lock around calls.
|
| lognormvariate(self, mu, sigma)
| Log normal distribution.
|
| If you take the natural logarithm of this distribution, you'll get a
| normal distribution with mean mu and standard deviation sigma.
| mu can have any value, and sigma must be greater than zero.
|
| normalvariate(self, mu, sigma)
| Normal distribution.
|
| mu is the mean, and sigma is the standard deviation.
|
| paretovariate(self, alpha)
| Pareto distribution. alpha is the shape parameter.
|
| randint(self, a, b)
| Return random integer in range [a, b], including both end points.
|
| randrange(self, start, stop=None, step=1, _int=<type 'int'>, _maxwidth=9007199254740992L)
| Choose a random item from range(start, stop[, step]).
|
| This fixes the problem with randint() which includes the
| endpoint; in Python this is usually not what you want.
|
| sample(self, population, k)
| Chooses k unique random elements from a population sequence.
|
| Returns a new list containing elements from the population while
| leaving the original population unchanged. The resulting list is
| in selection order so that all sub-slices will also be valid random
| samples. This allows raffle winners (the sample) to be partitioned
| into grand prize and second place winners (the subslices).
|
| Members of the population need not be hashable or unique. If the
| population contains repeats, then each occurrence is a possible
| selection in the sample.
|
| To choose a sample in a range of integers, use xrange as an argument.
| This is especially fast and space efficient for sampling from a
| large population: sample(xrange(10000000), 60)
|
| shuffle(self, x, random=None)
| x, random=random.random -> shuffle list x in place; return None.
|
| Optional arg random is a 0-argument function returning a random
| float in [0.0, 1.0); by default, the standard random.random.
|
| triangular(self, low=0.0, high=1.0, mode=None)
| Triangular distribution.
|
| Continuous distribution bounded by given lower and upper limits,
| and having a given mode value in-between.
|
| http://en.wikipedia.org/wiki/Triangular_distribution
|
| uniform(self, a, b)
| Get a random number in the range [a, b) or [a, b] depending on rounding.
|
| vonmisesvariate(self, mu, kappa)
| Circular data distribution.
|
| mu is the mean angle, expressed in radians between 0 and 2*pi, and
| kappa is the concentration parameter, which must be greater than or
| equal to zero. If kappa is equal to zero, this distribution reduces
| to a uniform random angle over the range 0 to 2*pi.
|
| weibullvariate(self, alpha, beta)
| Weibull distribution.
|
| alpha is the scale parameter and beta is the shape parameter.
|
| ----------------------------------------------------------------------
| Data descriptors inherited from Random:
|
| __dict__
| dictionary for instance variables (if defined)
|
| __weakref__
| list of weak references to the object (if defined)
|
| ----------------------------------------------------------------------
| Methods inherited from _random.Random:
|
| __getattribute__(...)
| x.__getattribute__('name') <==> x.name
|
| getrandbits(...)
| getrandbits(k) -> x. Generates a long int with k random bits.
|
| ----------------------------------------------------------------------
| Data and other attributes inherited from _random.Random:
|
| __new__ = <built-in method __new__ of type object>
| T.__new__(S, ...) -> a new object with type S, a subtype of T FUNCTIONS
betavariate(self, alpha, beta) method of Random instance
Beta distribution. Conditions on the parameters are alpha > 0 and beta > 0.
Returned values range between 0 and 1. choice(self, seq) method of Random instance
Choose a random element from a non-empty sequence. expovariate(self, lambd) method of Random instance
Exponential distribution. lambd is 1.0 divided by the desired mean. It should be
nonzero. (The parameter would be called "lambda", but that is
a reserved word in Python.) Returned values range from 0 to
positive infinity if lambd is positive, and from negative
infinity to 0 if lambd is negative. gammavariate(self, alpha, beta) method of Random instance
Gamma distribution. Not the gamma function! Conditions on the parameters are alpha > 0 and beta > 0. The probability distribution function is: x ** (alpha - 1) * math.exp(-x / beta)
pdf(x) = --------------------------------------
math.gamma(alpha) * beta ** alpha gauss(self, mu, sigma) method of Random instance
Gaussian distribution. mu is the mean, and sigma is the standard deviation. This is
slightly faster than the normalvariate() function. Not thread-safe without a lock around calls. getrandbits(...)
getrandbits(k) -> x. Generates a long int with k random bits. getstate(self) method of Random instance
Return internal state; can be passed to setstate() later. jumpahead(self, n) method of Random instance
Change the internal state to one that is likely far away
from the current state. This method will not be in Py3.x,
so it is better to simply reseed. lognormvariate(self, mu, sigma) method of Random instance
Log normal distribution. If you take the natural logarithm of this distribution, you'll get a
normal distribution with mean mu and standard deviation sigma.
mu can have any value, and sigma must be greater than zero. normalvariate(self, mu, sigma) method of Random instance
Normal distribution. mu is the mean, and sigma is the standard deviation. paretovariate(self, alpha) method of Random instance
Pareto distribution. alpha is the shape parameter. randint(self, a, b) method of Random instance
Return random integer in range [a, b], including both end points. random(...)
random() -> x in the interval [0, 1). randrange(self, start, stop=None, step=1, _int=<type 'int'>, _maxwidth=9007199254740992L) method of Random instance
Choose a random item from range(start, stop[, step]). This fixes the problem with randint() which includes the
endpoint; in Python this is usually not what you want. sample(self, population, k) method of Random instance
Chooses k unique random elements from a population sequence. Returns a new list containing elements from the population while
leaving the original population unchanged. The resulting list is
in selection order so that all sub-slices will also be valid random
samples. This allows raffle winners (the sample) to be partitioned
into grand prize and second place winners (the subslices). Members of the population need not be hashable or unique. If the
population contains repeats, then each occurrence is a possible
selection in the sample. To choose a sample in a range of integers, use xrange as an argument.
This is especially fast and space efficient for sampling from a
large population: sample(xrange(10000000), 60) seed(self, a=None) method of Random instance
Initialize internal state from hashable object. None or no argument seeds from current time or from an operating
system specific randomness source if available. If a is not None or an int or long, hash(a) is used instead. setstate(self, state) method of Random instance
Restore internal state from object returned by getstate(). shuffle(self, x, random=None) method of Random instance
x, random=random.random -> shuffle list x in place; return None. Optional arg random is a 0-argument function returning a random
float in [0.0, 1.0); by default, the standard random.random. triangular(self, low=0.0, high=1.0, mode=None) method of Random instance
Triangular distribution. Continuous distribution bounded by given lower and upper limits,
and having a given mode value in-between. http://en.wikipedia.org/wiki/Triangular_distribution uniform(self, a, b) method of Random instance
Get a random number in the range [a, b) or [a, b] depending on rounding. vonmisesvariate(self, mu, kappa) method of Random instance
Circular data distribution. mu is the mean angle, expressed in radians between 0 and 2*pi, and
kappa is the concentration parameter, which must be greater than or
equal to zero. If kappa is equal to zero, this distribution reduces
to a uniform random angle over the range 0 to 2*pi. weibullvariate(self, alpha, beta) method of Random instance
Weibull distribution. alpha is the scale parameter and beta is the shape parameter. DATA
__all__ = ['Random', 'seed', 'random', 'uniform', 'randint', 'choice',...
help(random)
random.random() # 随机生成0.0到1.0间的的浮点数
random.randrange(start, stop[, step]) # 随机生成start到stop之间的整数(可以指定步长), start和step不是必须的
random.randint(a, b) # 随机生成a到b之间的整数
random.choice(seq) # 从非空序列seq返回一个随机的元素。如果序列是空的抛出IndexError
random.uniform(a, b) # 生成a到b之间的浮点数, a与b都为整形
random.shuffle(items) # 随机打乱一个序列,是原处修改
random.sample(population, k) # 从一个序列中选k个
练习:
>>> random.random() # 返回随机浮点数中的范围0.0 <= x < 1.0
0.8600361379435925
>>> random.randrange(90,100,2) # 随机生成90到100之间的数,步长为2
94
>>> random.randint(10,100) # 10到100之间的整数
62
>>> random.choice([10,20,30,40]) # 从一个序列中返回一个元素
10
>>> random.choice('abbacaedffabcde')
'a'
>>> random.uniform(1, 10) # 1,10之间的浮点
6.78650282776282
>> items = ['a','b','c','d','e','f','g'] # 随机打乱一个序列,原处修改
>>> random.shuffle(items)
>>> items
['a', 'g', 'b', 'f', 'd', 'e', 'c']
>>> random.sample([1, 2, 3, 4, 5], 3) # 从一个序列中选3个
[4, 1, 5]
>>> random.randint(122400,500000) # 随机6位数
307770
>>> random.randrange(122400,500000,2) # 随机6位数偶数
426194
>>> [random.randrange(10) for _ in xrange(20)] # 随机生成20个10以内的数字
[8, 0, 9, 5, 2, 7, 0, 2, 7, 6, 9, 4, 5, 3, 2, 5, 3, 8, 7, 4]
随机生成6位大写或小写字母
import string
import random def code(n=6, upper=False):
"""
随机生成n位大写或小写字母组成的验证码, 默认小写6位
parmas n: 随机n位, 默认小写6位
return: str
""" if not isinstance(n, int):
raise TypeError('Must be an integer') if n <= 0:
raise ValueError('Must be greater 0') result = ''.join(random.choice(string.ascii_uppercase) for _ in range(n)) if upper:
return result
else:
return result.lower() if __name__ == '__main__':
print(code()) # ydtwix
print(code(upper=True)) # DWLGRG
print(code(8)) # wkveigga
print(code(8, upper=True)) # TQCOVKUO
radom的更多相关文章
- Python模块(radom)
radom radom模块提供了随机生成对象的方法 Help on module random: NAME random - Random variable generators. FILE /usr ...
- 系统自动生成ID(比UUID.radom().tostring()要好看)
public class test1 { public static void main(String[] args) { char[] para = {'A','B','C','D','E','F' ...
- 模块的分类以及time与date time 模块 radom模块
1.标准库,或者内置模块,python解释器自带的,比如sys,os模块 2.开源模块,或者叫第三方模块,python就强大在这里. 3.自定义模块. 标准库: 1.时间模块time与datetime ...
- C# 随机数 Radom 循环生成同一的数字
错误:在一个循环结构中,利用下列代码生成随机数,发生生成的随机数是一样的! for (int i = 0; i < myArray.Length; i++) //给数组赋值 { Random m ...
- Python基础-时间模块和radom模块
时间模块 import time # 引入时间模块 print(time.time()) # 1508146954.9455004: 时间戳 print(time.clock()) # 计算CPU执行 ...
- loadrunner 生成随机参数 Radom相关
我也是刚开始进入测试行业,不过比较幸运的我之前做过开发,所以对代码比较熟悉,对loadrunner没有进行过系统的学习,也是通过自己的摸索慢慢的积累知识. 今天遇到项目中要我做一个压力测试,其中一些参 ...
- jQuery之ajax实现篇
jQuery的ajax方法非常好用,这么好的东西,你想拥有一个属于自己的ajax么?接下来,我们来自己做一个简单的ajax吧. 实现功能 由于jq中的ajax方法是用了内置的deferred模块,是P ...
- scala练习题1 基础知识
1, 在scala REPL中输入3. 然后按下tab键,有哪些方法可以被调用? 24个方法可以被调用, 8个基本类型: 基本的操作符, 等: 2,在scala REPL中,计算3的平方根,然 ...
- C# Random生成多个不重复的随机数万能接口
C#,Radom.Next()提供了在一定范围生成一个随机数的方法,我现在有个业务场景是给其他部门推送一些数据供他们做抽样检查处理,假设我的数据库里面有N条数据,现在要定期给其随机推送数据,我需要先拿 ...
随机推荐
- Dubbo简单理解
Dubbo 致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案.简单的说,Dubbo就是个服务框架,如果没有分布式的需求,其实是不需要用的,只有在分布式的时候,才有Dubbo这样 ...
- rapidjson使用
Value构造 Value对象最好先声明后初始化,如果声明直接初始化可能出错. rapidjson::Value a; a = val[i]; Value传参 Value传参,最好显式使用右值,如st ...
- PAT L1-020 帅到没朋友(模拟数组)
当芸芸众生忙着在朋友圈中发照片的时候,总有一些人因为太帅而没有朋友.本题就要求你找出那些帅到没有朋友的人. 输入格式: 输入第一行给出一个正整数N(≤100),是已知朋友圈的个数:随后N行,每行首先给 ...
- codeblocks不支持c++11的有效解决办法
首先cb支持c++11编程开发,但是不支持编译 看了网上好多,说setting里面设置一下就好了,16.01版本我安装了带ide的不带IDE的,安了好多次,但是就是没有那个选项 找不到c++11那个选 ...
- centos7下源码安装mysql5.7.16
一.下载源码包下载mysql源码包 http://mirrors.sohu.com/mysql/MySQL-5.7/mysql-5.7.16.tar.gz 二.安装约定: 用户名:mysql 安装目录 ...
- JsonConvert.SerializeObject 空值处理
var settings = new JsonSerializerSettings() { ContractResolver= new NullToEmptyStringResolver() }; v ...
- golang协程进行同步方法
1.使用chanel func main() { done := make(chan bool) ticker := time.NewTicker(time.Millisecond * 1000) g ...
- DB2数据库常用命令数据库学习
DB2数据库常用命令数据库学习你可以用 get snapshot for locks on XXX 看是那个表锁了,再从相关的操作去查原因吧 db2pd -d 库名 -locks和db2pd -d 库 ...
- Luogu 3959 [NOIP2017] 宝藏- 状压dp
题解 真的想不到这题状压的做法...听说还有跑的飞快的模拟退火,要是现场做绝对滚粗QAQ. 不考虑深度,先预处理出 $pt_{i, S}$ 表示让一个不属于 集合 $S$ 的 点$i$ 与点集 $S$ ...
- 201621123008《Java程序设计》第七周学习总结
1. 本周学习总结 1.1 思维导图:Java图形界面总结 2.书面作业 1. GUI中的事件处理 1.1 写出事件处理模型中最重要的几个关键词. 监听,事件源,事件,注册. 1.2 任意编写事件处理 ...