1 PY环境与变量

一 环境与文件形式

1.环境搭建http://jingyan.baidu.com/article/eae07827f7f2d01fec5485f7.html

2. python 则进入交互模式  exit() 则退出

    vim  1.py 则进入文本模式

3. syntax error 语法错误

4.文件形式

 1)  源代码

.py 形式   which python //则可以知道Python所在路径

 #!/usr/bin/python

print 'hello world'

2)字节代码

.pyc 的文件   import py_compile

                   py_compile.compile('hello.py')

执行只能用: python hello.pyc

3)优化代码

 .pyo 扩展名  Python -O -m py_compile hello.py

执行命令:python  1.pyo

二 变量名

1.变量名有字母,数字,下划线,数字不能开头,不能使用关键字

2. 未定义的变量会产生异常 NameError: name 'c' is not defined

3. id (a) 查看变量地址

三 运算与表达式

1. 运算符

   算术运算符  关系运算符 逻辑运算符

// 整除法 % 求余运算  ** 次方 3**2 3的平方

原文地址:https://www.cnblogs.com/verawang/p/5764055.html