1.convert 轉(zhuǎn)換
2.print
python2x print "hello"
python3x print ("hello")
python3x中print要加(),不然程序出錯(cuò)
3.典型的python文件結(jié)構(gòu)
/usr/bin/env python (1) 起始行
"this is a test module" (2) 模塊文檔(文檔字符串)
import sys
import os (3) 模塊導(dǎo)入(兩行代碼)
debug = True (4) (全局)變量定義
class FooClass(object):
"Foo class"
pass (5) 類定義(若有)
def test():
"test function"
foo = FooClass()
if dehug:
print "run test()" (6) 函數(shù)定義(若有)
if name == "main":
test() (7) 主程序