1、这里以sublime text3作为示范,先创建一个py文档。


2、def func1():
pass
def func2():
pass
这里创建两个函数,因为我们要设定子函数。

3、def func2():
return "Apple!"
print(func2())
比如我们要把这个设定为子函数,先设定内容。

4、def func1():
if func2() == "Apple!":
return "This is an apple!"
else:
return "Null"
然后我们设定父函数,这里加入if判断,并且要把子函数加入。

5、print(func1())
我们运行一下父函数,就能看到由于if判断得出的结果。

6、def func1():
return func2("Apple")
def func2(x):
if x:
return True
else:
return Flase
print(func1())
如果要在子函数里面用if,让主函数用到,那么我们要在子函数里面设定参数。
