python 函数基础
来源:互联网 发布:27周胎儿发育标准数据 编辑:程序博客网 时间:2024/04/29 04:36
#-*- coding:utf-8 -*-'''Created on 2016年12月16日@author: Administrator''''''定义函数 '''def sey_hi(): print("hi~");sey_hi()#调用函数"""传参数函数"""def sey_a_b(a,b): return a+bprint(sey_a_b(2, 4))def say_hell_hi(str): print("hello "+str+"!")say_hell_hi("jack")##实现对hello 打印四次def repest_str(str,tiems): repeated_str=str * tiems return repeated_strrepest_strings=repest_str("hello ", 4)print(repest_strings)print("hello "*4)##全局变量def foo(): global x print(str(x)) print(x)##默认参数的函数def fooo(s,t=1): repeated=s*t; return repeatedprint(fooo("jack",))##关键字参数 选择传入def func(a,b=10,c=8): print("a is ",a ,"b is ",b,"c is ",c)func(123,c=23) ##传入相应的关键字 如果指明关键字 那么顺序不太要#varargs 参数def print_paras(fpara,*nums,**words): ##nums 后台当做元组来对待 print("fpara "+str(fpara)) print("nums"+str(nums))# 后台当做字典来存储 print("words"+str(words))# 后台当做字典来存储print_paras("hello",1,3,5,7,words="python",anohter_words="java")#
0 0
- Python基础II---函数基础
- 【Python基础】函数
- Python基础07 函数
- python基础(3)-函数
- Python基础07 函数
- Python基础07 函数
- Python socket基础函数
- Python基础07 函数
- 【Python】读书笔记,基础函数
- Python<11>函数基础
- Python基础07 函数
- Python基础07 函数
- Python基础3--函数
- Python基础07 函数
- Python基础07 函数
- Python基础:常用函数
- 【Python.基础】main函数
- 7.Python基础 函数
- 第十六周项目1(3)——直接选择排序
- iOS 高德地图API不能定位及INVALID_USER_SCODE问题
- Android 关于getViewTreeObserver()
- PHP学习指南
- 数据挖掘中的线性代数工具
- python 函数基础
- linux读书摘要--vim文本编辑器
- 正方教务系统课表成绩抓取核心代码解析,你也能实现超级课程表的功能
- 使用JSP技术实现百万富翁猜数字游戏
- Codeforces 742A-Arpa’s hard exam and Mehrdad’s naive cheat(快速幂)
- 第十六周项目1(4)——堆排序
- 转移说明符
- system调用和posix说明
- PHP回调函数