Variable declaration, initialization, delete variables, garbage collection mechanism, assignment, constants, built-in data types

A variable declaration and assignment:

Variable declaration and assignment for telling a variable bound to an object

Format is as follows:

                1. variable name = expression   

Second, delete variables and garbage collection:

       You can delete by the del statement variable is not used, if the object is not variable references, it will be recovered garbage collector, clear memory space.

       a = 123 

       of the  

 Third, the chain assignment:

        Assignment chain for the same object multiple variables assignment

        x = y = 123 is equivalent to: x = 123; y = 123

        Series unpacking assignment :( number must be consistent)

        a, b, c = 4,5,6 corresponds to a = 4; b = 5; c = 6

        Example: a, b = 1,2

                 a,b = b,a

Fourth, the constant

       python does not support constant, that is, no grammar rules limit change a constant value. We can only naming convention constants,

       And not in the constant logic value to make changes.

      MAX_SPEED = 120

      print(MAX_SPEED)     

Fifth, each object has a type, python most basic built-in data types:

       1. Plastic: 123 2. Float: 3.14 3. decimal Boolean: true and false indicates, contains only True, False 4. string types: the sequence of characters. "Abc"; "Beijing";

 

  

                                             

Guess you like

Origin www.cnblogs.com/yingxiongguixing/p/12163890.html