函数定义:一组代码片段用函数名封装起来,通过函数名的方式调用执行。
特性:
1.减少重复代码
2.使程序易扩展
3.使程序易维护
语法定义:
1 def sayhi(): 2 print("hello,I‘am function") 3 sayhi()
带参数的函数名:
1 def calc(x,y): 2 res = x * y 3 print(res) 4 c = calc(a,b) 5 print(c)
原文:http://www.cnblogs.com/wolfs685/p/6720830.html