zoukankan      html  css  js  c++  java
  • 第三篇:函数之嵌套

     1 #函数的嵌套调用:在调用一个函数的时,其内部的代码又调用其他的函数
     2 # def bar():
     3 #     print('from bar')
     4 #
     5 # def foo():
     6 #     print('from foo')
     7 #     bar()
     8 #
     9 # foo()
    10 
    11 
    12 # def max2(x,y):
    13 #     if x > y:
    14 #         return x
    15 #     else:
    16 #         return y
    17 #
    18 # def max4(a,b,c,d):
    19 #     res1=max2(a,b)
    20 #     res2=max2(res1,c)
    21 #     res3=max2(res2,d)
    22 #     return res3
    23 #
    24 # print(max4(1,2,3,4))
    25 
    26 
    27 #函数的嵌套定义:在一个函数的内部又定义了另外一个函数
    28 def f1():
    29     x=1
    30     def f2():
    31         print('from f2')
    32     # print(x)
    33     # print(f2)
    34     # f2()
    35 
    36 # f1=10
    37 # print(f1)
    38 
    39 f1()
    40 # f2()
    41 
    42 print(x)
  • 相关阅读:
    jQuery 插件
    jQuery 构造函数
    jQuery.merge()方法
    插入排序法
    归并排序法
    冒泡排序法
    选择排序法
    Jetty
    分布式锁&&redis
    Tomcat和设计模式
  • 原文地址:https://www.cnblogs.com/yspass/p/9325705.html
Copyright © 2011-2022 走看看