PYTHON Learning 0045: --- random function module Detailed --2019-8-11

1, taking a random number:
the random.randint (1,100) takes a random integer from 1 to 100, comprising 100.
PYTHON Learning 0045: --- random function module Detailed --2019-8-11
2, random.randrange (1,100) and on a similar, but that does not include 100.
PYTHON Learning 0045: --- random function module Detailed --2019-8-11
3, random.random (): generating random floating point numbers
PYTHON Learning 0045: --- random function module Detailed --2019-8-11
4, random.choice ( "sdfsf2323d23") returns a random element in the string:
PYTHON Learning 0045: --- random function module Detailed --2019-8-11
. 5, random.sample ( "sdfsf2323d23",. 3) returns from a given random string in 3 elements, display in list form:
PYTHON Learning 0045: --- random function module Detailed --2019-8-11
6 generates a random string:
first introduced into a module:
import string
this module has the following methods:
PYTHON Learning 0045: --- random function module Detailed --2019-8-11

PYTHON Learning 0045: --- random function module Detailed --2019-8-11
The method of the above data sources to solve the problem of random code, and then, the generated random data to said variable name assignment,
The random.choice ()
PYTHON Learning 0045: --- random function module Detailed --2019-8-11
can also be used in the form of a list of bars join method string becomes:
PYTHON Learning 0045: --- random function module Detailed --2019-8-11
7, it disrupted data (shuffling):
A = [0,1,2,3,4,5,6,7,8,9]
PYTHON Learning 0045: --- random function module Detailed --2019-8-11
PYTHON Learning 0045: --- random function module Detailed --2019-8-11

Guess you like

Origin blog.51cto.com/13543767/2428490