首页 > 其他 > 详细

函数的使用原则

时间:2018-09-25 20:09:59      阅读:132      评论:0      收藏:0      [点我收藏+]
# _*_ coding: utf-8 _*_


# 函数的使用应该分为两个明确的阶段
‘‘‘
第一阶段 定义阶段
def function():
#代码块
......

第二阶段 调用阶段
function() 会触发函数体代码的执行

‘‘‘
# 先定义后调用
# e.g.
# def function0():
# print(‘function0 test‘)
# function()
# function0 test

#函数嵌套
# def function1():
# print(‘function1 test‘)
#
# def function2():
# print(‘function2 test‘)
# function1()
# function2()
# function3 test
# function1 test

# def function3():
# print(‘function3 test‘)
# function4()
#
# def function4():
# print(‘function4 test‘)
# function3()
# function3 test
# function4 test

# def function5():
# print(‘function5 test‘)
# function6()
# function5()
#
# def function6()
# print(‘function6 test‘)

# def function6()
# ^
# SyntaxError: invalid syntax

函数的使用原则

原文:https://www.cnblogs.com/OutOfControl/p/9703015.html

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