python如何结束执行函数

在python中使用return语句结束执行函数,具体方法如下:

>>> def fun():

print 'ok'

>>> res=fun()

ok

>>> type(res)

>>> res==None

True

>>> def func():

print 98

return

>>> f=func()

98

>>> f

>>> type(f)

>>> f==None

True

Both comments and pings are currently closed.

Comments are closed.

Powered by KingAbc | 粤ICP备16106647号-2 | Loading Time‌ 0.225