首页 > 编程语言 > 详细

python学习之day4,函数

时间:2016-11-01 13:33:27      阅读:169      评论:0      收藏:0      [点我收藏+]

1.函数的定义:  函数是指将一组语句的集合通过一个名字(函数名)封装起来,要想执行这个函数,只需调用其函数名即可

   特性:

  1. 减少重复代码
  2. 使程序变的可扩展
  3. 使程序变得易维护

  语法定义:

1 def test():
2     print "this is test"
3 
4 test()

默认参数

1 def info(name,age,country="CN"):    #默认参数
2     print ‘‘‘name is  %s
3             age is   %d
4             country is %s‘‘‘%(name,age,country)
5 
6 info("liruixin",22)

 

python学习之day4,函数

原文:http://www.cnblogs.com/liruixin/p/6018854.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!