面向对象:---类---》class
面向过程:---过程---》def
函数式编程:---函数---》def
#函数
def fun1():
"""testing"""
print("in the fun1")
return 0
#过程
def fun2():
"""testing2"""
print("in the fun2")
x = fun1()
y = fun2()
print("from fun1 return is %s" %x)
print("from fun2 return is %s" %y)
#无参数的函数
# def lo():
# with open("test","a+") as f:
# f.write('end action\n')
#
# def f1():
# print("in the test1")
# lo()
#
# def f2():
# print("in the test2")
# return 0
#
# def f3():
# print("in the test3")
# return 1,'hello',['qjh'],{'name':'jhq'}
#
# x = f1()
# y = f2()
# z = f3()
# print(x)
# print(y)
# print(z)
#有参数的函数
def t1(x,y,z):
print(x)
print(y)
print(z)
# x = 1
# y = 2
#t1(y=2,x=1)#按自己的意愿赋值
#t1(1,2)#x,y是形参,1,2是实参
#t1(3,y=4,6)#这是错的,关键参数不能写在位置参数的前面 y=4是关键参数,6是位置参数
def t5(**kwargs):
print(kwargs)
t5(name='qjh',age=23,sex='boy')