Python函數(shù)構(gòu)建

函數(shù)的構(gòu)建格式

在Python中,函數(shù)的構(gòu)建要遵循一定的格式,如下所示:

  1. 函數(shù)代碼塊以 def 關(guān)鍵詞開頭,后接函數(shù)標(biāo)識(shí)符名稱和圓括號(hào) ()。
  2. 任何傳入?yún)?shù)和自變量必須放在圓括號(hào)中間,圓括號(hào)之間可以用于定義參數(shù)。
  3. 函數(shù)的第一行語句可以選擇性地使用文檔字符串—用于存放函數(shù)說明。
  4. 函數(shù)內(nèi)容以冒號(hào)起始,并且縮進(jìn)。
  5. return [表達(dá)式]結(jié)束函數(shù),選擇性地返回一個(gè)值給調(diào)用方。不帶表達(dá)式的return相當(dāng)于返回 None。

Python函數(shù)的構(gòu)建方法示意圖如下所示:

[圖片上傳失敗...(image-52b046-1551584695056)]

一個(gè)簡(jiǎn)單的函數(shù)構(gòu)建

在下面的例子中,構(gòu)建了一個(gè)將華氏度轉(zhuǎn)換為攝氏度的函數(shù),如下所示:

def fahrenheit_coverter(C):
    fahrenheit = C*9/5 +32
    return str(fahrenheit) +' F'
C2F = fahrenheit_coverter(35)
print(C2F)

將上述文件保存在C盤,命名為test.py,運(yùn)行結(jié)果如下所示:

C:\Users\20161111>python t.py
95.0 F

在交互模式下定義函數(shù)

如果在交互模式下面定義函數(shù),解釋器會(huì)顯示三個(gè)小點(diǎn)來提醒你定義還沒有完成,如下所示:

>>> def test_python():
...

在函數(shù)定義完畢的結(jié)尾,必須輸入一行空白行。定義函數(shù)會(huì)創(chuàng)建一個(gè)函數(shù)類的對(duì)象,如下所示:

>>> def test_python():
...     print("I test def function")
...
>>> test_python()
I test def function
>>>

第一行:def test_python(): 定義函數(shù)

第二行:print("I test def function") 輸入函數(shù)的內(nèi)容,前面要空四格

第三行:是一空行,輸入幾個(gè)空格,直接回車就行;

第四行:繼續(xù)回車,函數(shù)創(chuàng)建完畢,輸入test_python(),顯示結(jié)果。

函數(shù)的嵌套

在函數(shù)中也能創(chuàng)建函數(shù),如下面的案例:

def print_lyrics():
    print("I'm a lumberjack, and I'm okay.")
    print("I sleep all night and I work all day.")
def repeat_lyrics():
    print_lyrics()
repeat_lyrics()

運(yùn)行后如下所示:

C:\Users\20161111>python test.py
I'm a lumberjack, and I'm okay.
I sleep all night and I work all day.

函數(shù)的參數(shù)傳遞

在Python中,類型屬于對(duì)象,變量是沒有類型的,先看下面的代碼:

a = [1, 2, 3]
a = "Runoob"

在上述代碼中,[1, 2, 3]是List類型,"Runoob"是String類型,而變量a是沒有類型的,它僅僅是一個(gè)對(duì)象的引用(一個(gè)指針),它可以指向List類型的對(duì)象,也哦可以是指向String類型對(duì)象。

可更改(mutable)與不可更改(immutable)對(duì)象

在python中,strings,tuples,和numbers是不可更改的對(duì)象,而list,dict等則是可以修改的對(duì)象。

  1. 不可變類型:變量賦值a=5后再賦值a=10,這里實(shí)際是新生成一個(gè)int值對(duì)象10,再讓a指向它,而5被丟棄,不是改變a的值,相當(dāng)于新生成了a。
  2. 可變類型:變量賦值la=[1,2,3,4]后再賦值la[2]=5則是將listla的第三個(gè)元素值更改,本身la沒有動(dòng),只是其內(nèi)部的一部分值被修改了。

python函數(shù)的參數(shù)傳遞:

  1. 不可變類型:如整數(shù)、字符串、元組。如fun(a),傳遞的只是a的值,沒有影響a對(duì)象本身。比如在fun(a)內(nèi)部修改a的值,只是修改另一個(gè)復(fù)制的對(duì)象,不會(huì)影響a本身。
  2. 可變類型:如列表,字典。如fun(la),則是將la真正的傳過去,修改后fun外部的la也會(huì)受影響

在python中,一切皆對(duì)象,嚴(yán)格意義上來講,我們不能說值傳遞還是引用傳遞,我們應(yīng)該說傳不可變對(duì)象和傳可變對(duì)象。

python傳不可變對(duì)象實(shí)例

看這個(gè)案例:

biotest@biotest-VirtualBox:~/python3/01basic$ cat para.py 
#!/usr/bin/python3

def ChangeInt(a):
    a = 10

b = 2
ChangeInt(b)
print(b)
# The result is 2

biotest@biotest-VirtualBox:~/python3/01basic$ python3 para.py 
2

在這個(gè)案例中,有int對(duì)象2,指向它的變量是b,在傳遞給ChangeInt函數(shù)時(shí),按傳值的方式復(fù)制了變量b,a和b都指向了同一個(gè)Int對(duì)象,在a=10時(shí),則新生成一個(gè)int值對(duì)象10,并讓a指向它。

python傳可變對(duì)象實(shí)例

可變對(duì)象在函數(shù)里修改了參數(shù),那么在調(diào)用這個(gè)函數(shù)的函數(shù)里,原始的參數(shù)也被改變了,如下所示:

biotest@biotest-VirtualBox:~/python3/01basic$ cat para2.py
#!/usr/bin/python3

def changeme(mylist):
    mylist.append([1,2,3,4])
    print("The value inside function is: ",mylist)
    return

mylist=[10,20,30]
changeme(mylist)
print("The value outside function is: ",mylist)
biotest@biotest-VirtualBox:~/python3/01basic$ python3 para2.py
The value inside function is:  [10, 20, 30, [1, 2, 3, 4]]
The value outside function is:  [10, 20, 30, [1, 2, 3, 4]]

傳入函數(shù)的和在末尾添加新內(nèi)容的對(duì)象用的是同一個(gè)引用,因此輸出了相同的結(jié)果。

函數(shù)的參數(shù)

以下是調(diào)用函數(shù)時(shí)可使用的正式參數(shù)類型:

  1. 必需參數(shù)
  2. 關(guān)鍵字參數(shù)
  3. 默認(rèn)參數(shù)
  4. 不定長(zhǎng)參數(shù)

必需參數(shù)

必需參數(shù)須以正確的順序傳入函數(shù)。調(diào)用時(shí)的數(shù)量必須和聲明時(shí)的一樣。調(diào)用printme()函數(shù),你必須傳入一個(gè)參數(shù),不然會(huì)出現(xiàn)語法錯(cuò)誤,如下所示:

biotest@biotest-VirtualBox:~/python3/01basic$ cat function1.py 
#!/usr/bin/python3

def printme(str):
    print(str)
    return

printme()
biotest@biotest-VirtualBox:~/python3/01basic$ python3 function1.py 
Traceback (most recent call last):
  File "function1.py", line 7, in <module>
    printme()
TypeError: printme() missing 1 required positional argument: 'str'

關(guān)鍵字參數(shù)

關(guān)鍵字參數(shù)和函數(shù)調(diào)用關(guān)系緊密,函數(shù)調(diào)用使用關(guān)鍵字參數(shù)來確定傳入的參數(shù)值。使用關(guān)鍵字參數(shù)允許函數(shù)調(diào)用時(shí)參數(shù)的順序與聲明時(shí)不一致,因?yàn)?Python 解釋器能夠用參數(shù)名匹配參數(shù)值。以下實(shí)例在函數(shù) printme() 調(diào)用時(shí)使用參數(shù)名:

biotest@biotest-VirtualBox:~/python3/01basic$ cat function2.py 
#!/usr/bin/python3

def printme(str):
    print(str)
    return

printme(str="Runoob tutorial")
biotest@biotest-VirtualBox:~/python3/01basic$ python3 function2.py 
Runoob tutorial

以下實(shí)例中演示了函數(shù)參數(shù)的使用不需要使用指定順序:

biotest@biotest-VirtualBox:~/python3/01basic$ cat function3.py 
#!/usr/bin/python3

def printinfo(name, age):
    print("Name: ",name)
    print("Age: ",age)
    return

printinfo(age=50,name="runoob")
printinfo("Zhang",20)
printinfo(20,"Zhang")
biotest@biotest-VirtualBox:~/python3/01basic$ python3 function3.py 
Name:  runoob
Age:  50
Name:  Zhang
Age:  20
Name:  20
Age:  Zhang

從結(jié)果來看,如果不按順序輸入?yún)?shù),那么可以使用賦值語句將實(shí)參直接賦值給相應(yīng)的形參。

默認(rèn)參數(shù)

調(diào)用函數(shù)時(shí),如果沒有傳遞參數(shù),則會(huì)使用默認(rèn)參數(shù)。以下實(shí)例中如果沒有傳入age參數(shù),則使用默認(rèn)值:

biotest@biotest-VirtualBox:~/python3/01basic$ cat function4.py 
#!/usr/bin/python3

def printinfo(name,age=35):
    print("Name: ",name)
    print("Age: ",age)
    return

printinfo(age=50, name="runoob")
print("------------------------")
printinfo(name="runoob")
printinfo(20,"runoob")
printinfo("runoob",20)
biotest@biotest-VirtualBox:~/python3/01basic$ python3 function4.py 
Name:  runoob
Age:  50
------------------------
Name:  runoob
Age:  35
Name:  20
Age:  runoob
Name:  runoob
Age:  20

不定長(zhǎng)參數(shù)

你可能需要一個(gè)函數(shù)能處理比當(dāng)初聲明時(shí)更多的參數(shù)。這些參數(shù)叫做不定長(zhǎng)參數(shù),和上述2種參數(shù)不同,聲明時(shí)不會(huì)命名?;菊Z法如下:

def functionname([formal_args,] *var_args_tuple ):
   "函數(shù)_文檔字符串"
   function_suite
   return [expression]

加了星號(hào)(*)的變量名會(huì)存放所有未命名的變量參數(shù)。如果在函數(shù)調(diào)用時(shí)沒有指定參數(shù),它就是一個(gè)空元組。我們也可以不向函數(shù)傳遞未命名的變量。如下實(shí)例:

biotest@biotest-VirtualBox:~/python3/01basic$ cat function5.py 
#!/usr/bin/python3

def printinfo(arg1, *vartuple):
    print("Output: ")
    print(arg1)
    for var in vartuple:
        print(var)
    return

printinfo(10)
printinfo(11,12,13)
biotest@biotest-VirtualBox:~/python3/01basic$ python3 function5.py 
Output: 
10
Output: 
11
12
13

匿名函數(shù)lambda

python使用lambda來創(chuàng)建匿名函數(shù)。所謂匿名,意即不再使用def語句這樣標(biāo)準(zhǔn)的形式定義一個(gè)函數(shù),它的特點(diǎn)如下:

  1. lambda只是一個(gè)表達(dá)式,函數(shù)體比def簡(jiǎn)單很多。
  2. lambda的主體是一個(gè)表達(dá)式,而不是一個(gè)代碼塊。僅僅能在lambda表達(dá)式中封裝有限的邏輯進(jìn)去。
  3. lambda函數(shù)擁有自己的命名空間,且不能訪問自己參數(shù)列表之外或全局命名空間里的參數(shù)。
  4. 雖然lambda函數(shù)看起來只能寫一行,卻不等同于C或C++的內(nèi)聯(lián)函數(shù),后者的目的是調(diào)用小函數(shù)時(shí)不占用棧內(nèi)存從而增加運(yùn)行效率。

語法格式如下所示:

lambda [arg1 [,arg2,.....argn]]:expression

看一個(gè)簡(jiǎn)單的例子:

biotest@biotest-VirtualBox:~/python3/01basic$ cat lambda.py 
#!/usr/bin/python3

sum = lambda arg1, arg2: arg1 + arg2
# 這里就是定義了一個(gè)函數(shù),這個(gè)函數(shù)實(shí)現(xiàn)的功能就是兩個(gè)數(shù)字相加

print("The value summed is :  ",sum(10, 20))
print("The value summed is :  ",sum(20,20))
biotest@biotest-VirtualBox:~/python3/01basic$ python3 lambda.py 
The value summed is :   30
The value summed is :   40

上面的這個(gè)案例如果改成常規(guī)的函數(shù)寫法,則是如下所示:

biotest@biotest-VirtualBox:~/python3/01basic$ cat lambda.py 
#!/usr/bin/python3

sum = lambda arg1, arg2: arg1 + arg2

print("The value summed is :  ",sum(10, 20))
print("The value summed is :  ",sum(20,20))
biotest@biotest-VirtualBox:~/python3/01basic$ python3 lambda.py 
The value summed is :   30
The value summed is :   40

匿名函數(shù)與普通函數(shù)的區(qū)別

看下面的一段代碼:

biotest@biotest-VirtualBox:~/python3/03file$ cat lambda.py 
#!/usr/bin/python3

def add(a,b):
    return a+b
a=2
b=3
print('a+b=', add(a,b))

a=2
b=3
addl = lambda a,b:a+b
print('a+b=',addl(a,b))

print('type(add(a,b)):',type(add(a,b)))
print('type(addl):',type(addl))

biotest@biotest-VirtualBox:~/python3/03file$ python3 lambda.py 
a+b= 5
a+b= 5
type(add(a,b)): <class 'int'>
type(addl): <class 'function'>

從上面我們可以看見add(a,b)的類型是int,而addl(a,b)的類型則是函數(shù)。從這里也能看出Lambda表達(dá)式確實(shí)是一種函數(shù)的表示方式。lambda的一般形式是關(guān)鍵字lambda后面跟一個(gè)或多個(gè)參數(shù),緊跟一個(gè)冒號(hào),以后是一個(gè)表達(dá)式。lambda是一個(gè)表達(dá)式而不是一個(gè)語句。它能夠出現(xiàn)在python語法不允許def出現(xiàn)的地方。

lambda案例第1:快速組建列表

>>> list1 = lambda x:x**2
>>> l = [list1(i) for i in range(10)]
>>> print(l)
[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]

lambda函數(shù):減少函數(shù)命名

biotest@biotest-VirtualBox:~/python3/03file$ cat lambda1.py 
#!/usr/bin/python3

def eat(f):
    def many(n):
        return n*f
    return many
food = input('What kind of fruti do you like?')
f = eat(food)
print(f(5))
biotest@biotest-VirtualBox:~/python3/03file$ python3 lambda1.py 
What kind of fruti do you like? Yes
 Yes Yes Yes Yes Yes

上述代碼改寫為lambda則是如下所示:

def eat(f):
    return lambda n:f*n
    
food = input('What kind of fruit do you like?')
f = eat(food)
print(f(5))

再看一個(gè)案例:

biotest@biotest-VirtualBox:~/python3/03file$ cat original.py # 這是原代碼
#!/usr/bin/python3
freshfruit = [' banana',' loganberry ','passion fruit'] # 建立一個(gè)列表
print(freshfruit) #顯示列表,發(fā)現(xiàn)前2個(gè)元素有空格
list3 =[w.strip() for w in freshfruit] # 去除空格
print(list3) #空格去掉后的效果

biotest@biotest-VirtualBox:~/python3/03file$ python3 original.py 
[' banana', ' loganberry ', 'passion fruit']
['banana', 'loganberry', 'passion fruit']

biotest@biotest-VirtualBox:~/python3/03file$ cat original_trans.py # 改寫為lambda形式
#!/usr/bin/python3

freshfruit = [' banana',' loganberry ','passion fruit']
list3 = list(map(lambda x:x.strip(),freshfruit))
# lambda x:x.strip()這里就相當(dāng)于一個(gè)函數(shù),map則是將這個(gè)函數(shù)映射到freshfruit的每個(gè)元素上
print(list3)
biotest@biotest-VirtualBox:~/python3/03file$ python3 original_trans.py 
['banana', 'loganberry', 'passion fruit']

案例:使用列表推導(dǎo)式實(shí)現(xiàn)嵌套列表的平鋪,如下所示:

>>> vec = [[1,2,3],[4,5,6],[7,8,9,10]]
>>> print([num for elem in vec for num in elem])
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

這個(gè)列表推導(dǎo)式中有2個(gè)循環(huán),第1個(gè)循環(huán)可以看作是外循環(huán),執(zhí)行得慢,第2個(gè)循環(huán)是內(nèi)循環(huán),執(zhí)行得快,上面代碼等價(jià)于下面的:

biotest@biotest-VirtualBox:~/python3/03file$ cat test1.py 
#!/usr/bin/python3

vec = [[1,2,3],[4,5,6],[7,8,9,10]]
result = []
for elem in vec:
    for num in elem:
        result.append(num)
print(result)
biotest@biotest-VirtualBox:~/python3/03file$ python3 test1.py 
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

案例:過濾掉不合條件的元素

列表推導(dǎo)式中可以使用if語句來進(jìn)行篩選,只在結(jié)果列表中保留符合條件的元素,下面的代碼是過濾當(dāng)前目錄下的所有文件,只保留以.py結(jié)尾的文件,如下所示:

>>> import os
>>> print([filename for filename in os.listdir('.') if filename.endswith('.py')])
['a.py', 'count_line.py', 'practice.py', 'python.py', 't.py']

代碼解釋:

  1. os.listdir()方法用于返回指定的文件夾包含的文件或文件夾的名字的列表。這個(gè)列表以字母順序,括號(hào)中的參數(shù)可以是路徑,例如c:\downloads,也可以不加,用'.'來表示。
  2. endswith()方法用于判斷字符串是否以指定后綴結(jié)尾,如果以指定后綴結(jié)尾返回True,否則返回False。可選參數(shù)"start"與"end"為檢索字符串的開始與結(jié)束位置。

案例:過濾滿足一定條件的元素

>>> list4= [-1, -4, 6, 7.5 ,-2.3, 9, -11]
>>> print(list4)
[-1, -4, 6, 7.5, -2.3, 9, -11]
>>> result = [i for i in list4 if i < 0]
>>> print(result)
[-1, -4, -2.3, -11]

帶有返回值的函數(shù)

return[表達(dá)式]語句用于退出函數(shù),選擇性地向調(diào)用方返回一個(gè)表達(dá)式。不帶參數(shù)值的return語句返回None,如下所示:

biotest@biotest-VirtualBox:~/python3/01basic$ cat return.py 
#!/usr/bin/python3

def sum(arg1, arg2):
    total = arg1 + arg2
    print("Inside function is :  ",total)
    return total

total = sum(10, 20)
print("Outside function is : ",total)

biotest@biotest-VirtualBox:~/python3/01basic$ python3 return.py 
Inside function is :   30
Outside function is :  30

變量作用域

Python中,程序的變量并不是在哪個(gè)位置都可以訪問的,訪問權(quán)限決定于這個(gè)變量是在哪里賦值的。變量的作用域決定了在哪一部分程序可以訪問哪個(gè)特定的變量名稱。Python的作用域一共有4種,分別是:

  1. L(Local)局部作用域

  2. E(Enclosing)閉包函數(shù)外的函數(shù)中

  3. G(Global)全局作用域

  4. B(Built-in)內(nèi)建作用域

Pyhton以L–>E–>G–>B的規(guī)則查找,即:在局部找不到,便會(huì)去局部外的局部找(例如閉包),再找不到就會(huì)去全局找,再者去內(nèi)建中找,如下所示:

x = int(2.9)  # 內(nèi)建作用域
 
g_count = 0  # 全局作用域
def outer():
    o_count = 1  # 閉包函數(shù)外的函數(shù)中
    def inner():
        i_count = 2  # 局部作用域

Python中只有模塊(module)類(class)以及函數(shù)(def、lambda)才會(huì)引入新的作用域,其它的代碼塊(如if/elif/else/、try/except、for/while等)是不會(huì)引入新的作用域的,也就是說這些語句內(nèi)定義的變量,外部也可以訪問,如下代碼:

>>> if True:
...     msg = "I am a learner"
...
>>> msg
'I am a learner'

在這個(gè)案例中,msg變量定義在if語句塊中,但外部還是可以訪問的。如果將msg定義在函數(shù)中,則它就是局部變量,外部不能訪問,如下所示:

biotest@biotest-VirtualBox:~/python3/01basic$ cat local_variable.py 
#!/usr/bin/python3

def test():
    msg_inner = "I am a learner"

print(msg_inner)

biotest@biotest-VirtualBox:~/python3/01basic$ python3 local_variable.py 
Traceback (most recent call last):
  File "local_variable.py", line 6, in <module>
    print(msg_inner)
NameError: name 'msg_inner' is not defined

從錯(cuò)誤提示就能看出,msg_inner并示未定義,因?yàn)樗蔷植孔兞?,只能在函?shù)內(nèi)部使用。

全局變量和局部變量

定義在函數(shù)內(nèi)部的變量擁有一個(gè)局部作用域,定義在函數(shù)外的擁有全局作用域。局部變量只能在其被聲明的函數(shù)內(nèi)部訪問,而全局變量可以在整個(gè)程序范圍內(nèi)訪問。調(diào)用函數(shù)時(shí),所有在函數(shù)內(nèi)聲明的變量名稱都將被加入到作用域中,如下所示:

biotest@biotest-VirtualBox:~/python3/01basic$ cat global_local_variable.py 
#!/usr/bin/python3

total = 0 
# this is a global variable

def sum(arg1, arg2):
    total = arg1 + arg2
    # Here, total is a local variable
    print("Variable inside function is local variable: ",total)
    return total

sum(10, 20)
print("Variable outside function is global variable: ",total)
biotest@biotest-VirtualBox:~/python3/01basic$ python3 global_local_variable.py 
Variable inside function is local variable:  30
Variable outside function is global variable:  0

global和nonlocal關(guān)鍵字

當(dāng)內(nèi)部作用域想修改外部作用域的變量時(shí),就要用到global和nonlocal關(guān)鍵字,在下面的案例中,修改了全局變量num:

biotest@biotest-VirtualBox:~/python3/01basic$ cat nonlocal.py 
#!/usr/bin/python3

num = 1
def fun1():
    global num # need to keyword "global" for statement
    print(num)
    num = 123
    print(num)

fun1()

biotest@biotest-VirtualBox:~/python3/01basic$ python3 nonlocal.py 
1
123

如果要修改嵌套作用域(enclosing作用域,外層非全局作用域)中的變量則需要nonlocal關(guān)鍵字了,如下所示:

biotest@biotest-VirtualBox:~/python3/01basic$ cat nonlocal2.py 
#!/usr/bin/python3

def outer():
    num = 10
    def inner():
        nonlocal num 
        num = 100
        print(num)
    inner()
    print(num)
outer()
biotest@biotest-VirtualBox:~/python3/01basic$ python3 nonlocal2.py 
100
100

再看一個(gè)案例:

biotest@biotest-VirtualBox:~/python3/01basic$ cat action_scope_error.py 
#!/usr/bin/python3

a = 10
def test():
    a = a + 1
    print(a)
test()
biotest@biotest-VirtualBox:~/python3/01basic$ python3 action_scope_error.py 
Traceback (most recent call last):
  File "action_scope_error.py", line 7, in <module>
    test()
  File "action_scope_error.py", line 5, in test
    a = a + 1
UnboundLocalError: local variable 'a' referenced before assignment

錯(cuò)誤信息為局部作用域引用錯(cuò)誤,因?yàn)閠est函數(shù)中的a使用的是局部變量,未定義,無法修改。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 第5章 函數(shù)和函數(shù)式編程 5.1 引言函數(shù)是組織好的,可重復(fù)使用的,用來實(shí)現(xiàn)單一,或相關(guān)聯(lián)功能的代碼段。函數(shù)...
    VIVAFT閱讀 1,074評(píng)論 0 5
  • 本文的主題都是關(guān)于函數(shù)的??1. 函數(shù)的語法;??2. 函數(shù)的對(duì)象;??3. 函數(shù)裝飾器;??4. lambda表...
    楊強(qiáng)AT南京閱讀 949評(píng)論 0 1
  • http://python.jobbole.com/85231/ 關(guān)于專業(yè)技能寫完項(xiàng)目接著寫寫一名3年工作經(jīng)驗(yàn)的J...
    燕京博士閱讀 7,791評(píng)論 1 118
  • 日語,被西方人稱為“魔鬼的語言”。 何出此言?是否意指日語這門語言很難學(xué)? 在我看來,不難 但 也難。 不難, 因...
    螢_閱讀 1,007評(píng)論 2 3
  • 北方真正的春天,是從四月開始。 初春,渭北旱塬的風(fēng)粗糲撲過,冷冽干燥,不帶一絲溫柔。田野許久不曾見雨,土地皴裂出一...
    雨蕭_7e68閱讀 326評(píng)論 0 0

友情鏈接更多精彩內(nèi)容