python全栈开发笔记---------变量小结

变量是什么?

           变:变化,重在变字,量:计量,衡量,表示一种状态。

           变量字面理解就是一个可能改变的量,也就是这个值是不固定的。

变量名:

          a.数字

          b.字母

          c.下划线

变量的定义

    level = 1 

    level : 变量名, = :赋值符号,1 :值

   PS:

          1.数字不能开头

          2.不能用关键字:(查看所有的关键字:help("keywords"))

Here is a list of the Python keywords.  Enter any keyword to get more help.

and                 elif                import              return
as                  else                in                  try
assert              except              is                  while
break               finally             lambda              with
class               for                 not                 yield
continue            from                or
def                 global              pass
del                 if                  raise

       3.不要和python内置的东西重复 。 比如sum  。虽然他不是关键字。 但是他是系统内置的,如果用它变量了。 那么就破坏了系统内置的功能了。

       4.变量名尽量有意义。(变量表示的某种意义)

猜你喜欢

转载自www.cnblogs.com/kangming-/p/9822238.html