Python Note: common functions and classes

1、OrderedDict 

  Function: according to order of addition into a dictionary record key pair (s)

  格式:from collections import OrderedDict 

 

2, Randine ()

  Function: a function of generating a random number:

  Format: from randon import randint

        x = randint (1,100) # 1-100 generates a random number in

3、split( )

  Function: a character string, a space as delimiter, split into a plurality of portions, and these portions are stored in a list

  Format: variable name .split ()

  Description: This function only temporarily displayed, no changes to the variable!

  example: 

     Code:    name = 'the I Love the Python!'

          x=name.split()

           print(x)
         print(name)

 

     Results:    [ 'the I', 'Love', 'the Python!']

         I love Python!

  

Guess you like

Origin www.cnblogs.com/wssking/p/11524011.html