7-4python函数-嵌套使用

简介: 一个函数里面又调用了 另外一个函数,这就是函数嵌套调用。

一个函数里面又调用了 另外一个函数,这就是函数嵌套调用。

如果函数 test2 中,调用了另外一个函数 test1

那么执行到调用 test1 函数时,会先把函数 test1 中的任务都执行完

才会回到 test2 中调用函数 test1 的位置,继续执行后续代码

# 一个函数里面又调用另一个函数
def test1():
    print("我是test1")
def my_func():
    print("我是my_func")
def test2():  #如果不调用test2函数,那么test1和my_func都不执行
    test1()  # test2 内部调用了test1
    my_func()
test2()  # 程序第一条执行的语句
执行结果
"D:\Program Files1\Python\python.exe" D:/Pycharm-work/pythonTest/函数/13函数的嵌套.py
我是test1
我是my_func
Process finished with exit code 0


相关文章
|
4天前
|
Python
python函数进阶
python函数进阶
|
3天前
|
安全 Python
Python量化炒股的获取数据函数—get_industry()
Python量化炒股的获取数据函数—get_industry()
11 3
|
4天前
|
Python
Python sorted() 函数和sort()函数对比分析
Python sorted() 函数和sort()函数对比分析
|
3天前
|
Python
Python量化炒股的获取数据函数—get_security_info()
Python量化炒股的获取数据函数—get_security_info()
10 1
|
3天前
|
Python
Python量化炒股的获取数据函数— get_billboard_list()
Python量化炒股的获取数据函数— get_billboard_list()
|
3天前
|
安全 数据库 数据格式
Python量化炒股的获取数据函数—get_fundamentals()
Python量化炒股的获取数据函数—get_fundamentals()
10 0
|
4天前
|
算法 Python
Python编程的函数—内置函数
Python编程的函数—内置函数
|
4天前
|
Java C++ Python
30天拿下Python之函数
30天拿下Python之函数
|
4天前
|
Python
Python量化炒股的获取数据函数—get_index_weights()
Python量化炒股的获取数据函数—get_index_weights()
13 0
|
4天前
|
JavaScript Python
Python量化择时的技术指标函数
Python量化择时的技术指标函数
下一篇
无影云桌面