1.convert 转换
2.print
python2x print "hello"
python3x print ("hello")
python3x中print要加(),不然程序出错
3.典型的python文件结构
/usr/bin/env python (1) 起始行
"this is a test module" (2) 模块文档(文档字符串)
import sys
import os (3) 模块导入(两行代码)
debug = True (4) (全局)变量定义
class FooClass(object):
"Foo class"
pass (5) 类定义(若有)
def test():
"test function"
foo = FooClass()
if dehug:
print "run test()" (6) 函数定义(若有)
if name == "main":
test() (7) 主程序