河北邢台最新消息今天,沈阳网站关键词优化哪里好,做网站购买备案域名,山东网优编程#xff1a;面向对象#xff1a;华山派-----类----class 面向过程#xff1a;少林派-----过程---def 一段段的函数和功能包含在过程中 函数式编程#xff1a;逍遥派---函数----def 过程就是没有return返回值的函数 函数的定义#xff1a;数学…编程面向对象华山派-----类----class 面向过程少林派-----过程---def 一段段的函数和功能包含在过程中 函数式编程逍遥派---函数----def 过程就是没有return返回值的函数 函数的定义数学函数的定义两个变量x和y,y2x; 编程语言中函数的定义函数是逻辑结构化和过程化的一种编程方法。 1 #定义函数2 def test(x):3 The function definition4 x15 return x #函数的完整定义6 7 def func1():8 testing9 print(in the func1)
10 return 0
11
12
13 #定义过程
14 def func2():
15 testing
16 print(in the func2)
17
18 #调用函数
19 xfunc1()
20 #调用过程
21 yfunc2()
22
23 print(from func1 return is %s%x) #返回0
24 print(from func2 %s%y)#返回None 函数式编程的优点可扩展、保持一致性、代码重用性 import timedef logger():time_format %Y-%m-%d %Xtime_current time.strftime(time_format)with open(a.txt,a) as f:f.write(%s end action\n%time_current)def test1():print(in the test1)logger()def test2():print(in the test2)logger()def test3():print(in the test3)logger()xtest1()
ytest2()
ztest3()转载于:https://www.cnblogs.com/xiaobai005/p/7828814.html