日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

Python学习之路:函数介绍

發布時間:2023/11/29 python 33 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Python学习之路:函数介绍 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

編程:面向對象:華山派----->類---->class

? ? ? ? ?面向過程:少林派----->過程--->def ?一段段的函數和功能包含在過程中

? ? ? ? ?函數式編程:逍遙派--->函數---->def

? ? ? ? ?過程就是沒有return返回值的函數

函數的定義:數學函數的定義,兩個變量x和y,y=2x;

編程語言中函數的定義:函數是邏輯結構化和過程化的一種編程方法。

1 #定義函數 2 def test(x): 3 "The function definition" 4 x+=1 5 return x #函數的完整定義 6 7 def func1(): 8 "testing" 9 print("in the func1") 10 return 0 11 12 13 #定義過程 14 def func2(): 15 "testing" 16 print("in the func2") 17 18 #調用函數: 19 x=func1() 20 #調用過程 21 y=func2() 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 %X'time_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()x=test1() y=test2() z=test3()

?

轉載于:https://www.cnblogs.com/xiaobai005/p/7828814.html

總結

以上是生活随笔為你收集整理的Python学习之路:函数介绍的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。