- coding
Ascii United States
A byte represents a character, man will be able to express
Uppercase letters 65-90 lowercase letters 97-122
265 positions
. 8 indicates a byte, 8bit = 1byte
GBK Chinese
It contains only the national language
English: follow ascii byte represents one character
Chinese: two bytes of a man
Examples: China using a . 4 bytes in 24 bit
Unicod Unicode common worldwide
The first two bytes to represent a character
2 bytes indicates a man
Uncommon words with 4 represents a character bytes
Disadvantages: relatively large memory footprint
8-UTF ( Unicode upgrade version)
A byte represents a character (in use ascii rules)
Europe: two bytes to represent a character
European countries: three bytes to represent one character
Python2 with the ascii encoding
Python3 using a utf-8 encoded
Encode coding
Decode decode
- random random decimal
- Random integer
Random Import # for generating a 0-1 random floating point number between 0 <n-<=. 1 Print ( " first random number: ", random.random ()) Print ( " the second random number: ", Random .random ()) # for two arguments, the output is floating decimal point, a is not necessarily than b laughing Print ( "THIRD Random", random.uniform (20,50)) Print (random.uniform (100 , 50)) # return a, b integer between incoming parameters must be an integer, a <B Print (the random.randint (10,50)) # random.randrange ([Start], [End], STEP ) Print (random.randrange (10,50,2)) # The random.choice (sequence) sequence which may be a sequence of elements in the list of print (random.choice ([1,2,3,4,5,6,7,8 ])) Print (random.randrange (10,100,5))
Print (The random.choice (Range (10,100,5))) # scrambled shuffling known as Li = [1,2,3,4,5,6,7,8,9] random.shuffle (Li) Print (Li) # acquired from the specified sequence k th element as a return segment sample function does not change the original list # acquire five elements returned from a fragment list print (random.sample ([1,2,3,4, 5,6,7,8,9], 5))
Random