博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Python之路,Day30 - Python基础-函数即“变量”
阅读量:2046 次
发布时间:2019-04-28

本文共 516 字,大约阅读时间需要 1 分钟。

函数即变量#示范一:函数名称foo  加了()的意思是调用def foo():    print('in the foo')   #函数体foo()可以理解为:函数体 print('in the foo') 是一幢大楼的某个房间;foo就是房间的门牌号码。变量同理,X=1    1是一幢大楼的某个房间;X就是房间的门牌号码。#示范二: 两个函数都存在,正常运行def bar():    print('in the bar')def foo():    print('in the foo')    bar()foo()#示范三: 两个函数都存在,正常运行。def foo():    print('in the foo')    bar()def bar():    print('in the bar')foo()#示范四: 运行报错,调用foo函数时,bar函数还未加载def foo():    print('in the foo')    bar()foo()def bar():    print('in the bar')

有的函数可以不用起名字  比如lambda(匿名函数)

calc = lambda x:x*3

转载地址:http://pblof.baihongyu.com/

你可能感兴趣的文章
谈谈编程思想
查看>>
iOS MapKit导航及地理转码辅助类
查看>>
检测iOS的网络可用性并打开网络设置
查看>>
简单封装FMDB操作sqlite的模板
查看>>
iOS开发中Instruments的用法
查看>>
如何修炼成某一领域的高手?
查看>>
TCP的那些事(上)
查看>>
TCP的那些事(下)
查看>>
Arcgis for ios笔记
查看>>
iOS常用宏定义
查看>>
被废弃的dispatch_get_current_queue
查看>>
什么是ActiveRecord
查看>>
有道词典for mac在Mac OS X 10.9不能取词
查看>>
关于“团队建设”的反思
查看>>
利用jekyll在github中搭建博客
查看>>
How will the new iPhone screen sizes affect iOS developers?
查看>>
在xcode5中修改整个项目名
查看>>
漫谈选人与培训
查看>>
【移动开发】Ken Burns特效的幻灯片
查看>>
iOS 8中CLLocationManager及MKMapView showUserLocation失败的解决办法
查看>>