- 语法结构
def function_name(p):
(tab) statement1
(tab) statement2
(tab) statement3
申明函数名尾部需要“:”
使用tab缩进区分语句结构
函数无返回类型
def test_a(): print ' Hello the bling' print ' www.bling.com' print 'Entry programme' test_a() print 'Leave programme' #打印 Entry programme Hello the bling www.bling.com Leave programme
函数定义-形参,参数可有、可无
# -*- coding: cp936 -*- def test_a(): print ' Hello the bling' print ' www.bling.com' def test_b(p1,p2):#函数定义,形参 print p1, print p2 print 'Entry programme' test_a() test_b('yml',',jun')#函数调用,实参 test_b(11,13) print 'Leave programme' #输出 Entry programme Hello the bling www.bling.com yml ,jun 11 13 Leave programme