-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunction.py
56 lines (43 loc) · 1.03 KB
/
function.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# -*- coding:utf-8 -*-
def func():
print("this is a function!")
def func_parm(b=[]):
print(b)
b.append("4")
def func_args(a, *args, **kwargs):
print(a)
print("args:", args)
print("kwargs:", kwargs)
def func_return(a):
if a == '123':
return True
elif a == '456':
return False
elif a == 'abc':
return a, 12
def func_out(func):
func
def func_inner1():
print("this is first inner")
def func_inner2():
print("this is second inner")
if __name__ == '__main__':
func()
a = [1, 2, 3]
func_parm(b=a)
print a
print("-------------")
func_parm()
func_parm()
print("-------------")
# 可变参数 args, 关键字参数 kwargs
func_args("123", "456", "789")
func_args("123", "456", "789", name="zhang", age=30)
print("-------------")
print(func_return('123'))
print(func_return('456'))
print(func_return('789'))
print(func_return('abc'))
print("-------------")
func_out(func_inner1())
func_out(func_inner2())