-
實(shí)例方法不同的是,這里有兩點(diǎn)需要特別注意:
類方法需要使用@classmethod來(lái)標(biāo)記為類方法,否則定義的還是實(shí)例方法查看全部 -
面向?qū)ο缶幊?/p>
查看全部 -
When you first get started in Evernote, you can probably get to what you need quickly. But as you start to add more notes, you may find that you don’t get around as fast as you used to. Scrolling, navigating, and searching—it all starts to take a little bit longer.
Thankfully, there’s a highly underrated feature that is here to help: note links.
A note link is exactly what it sounds like: a link that takes you from one note to another within Evernote. While this might not seem to be much of a game changer, this seemingly simple feature is actually a secret weapon to create structure and zoom around your notes.
We’ve rounded up everything you need to know about note links, from why they matter to how they work, and we’ll give you some ideas for using them. If you haven’t thought much of note links in the past (or even heard of them), it’s time to take a closer look.
查看全部 -
沒有在實(shí)例化對(duì)象中,調(diào)用并修改屬性時(shí),類屬性改變,對(duì)象相應(yīng)的屬性也會(huì)改變。
但在對(duì)象中,調(diào)用并修改了類屬性,則申請(qǐng)了新的空間,修改類的屬性不會(huì)改變對(duì)象的屬性。
應(yīng)該是這樣。
查看全部 -
def calc_prod(list_):
? ? def calc():
? ? ? ? j = 1
? ? ? ? for i in list_:
? ? ? ? ? ? j = j * i
? ? ? ? print(j)
? ? ? ? return j
? ? return calc
? ??
f = calc_prod([1,2,3])
f()
查看全部 -
def f(x):
? ? return x.title()? ?#把每個(gè)單詞的第一個(gè)字母轉(zhuǎn)化為大寫,其余小寫
? ??
for item in map(f,['alice', 'BOB', 'CanDY']):
? ? print item
查看全部 -
網(wǎng)絡(luò)爬蟲是典型的應(yīng)用程序,它的工作原理就是通過(guò)不斷的請(qǐng)求互聯(lián)網(wǎng)的頁(yè)面,并從回應(yīng)中解析獲取出有用的數(shù)據(jù);數(shù)據(jù)積累后,可以有很多用處。
查看全部 -
eval()函數(shù)可以把字符串轉(zhuǎn)換為等值的結(jié)果,比如eval('1+1'),得到結(jié)果為2。
查看全部 -
通過(guò)input()函數(shù),輸入的是字符串,需要轉(zhuǎn)換為數(shù)據(jù)類型
查看全部 -
Python 字典(Dictionary) items() 函數(shù)以列表返回可遍歷的(鍵, 值) 元組數(shù)組。
tinydict?=?{'Google':?'www.google.com',?'Runoob':?'www.runoob.com',?'taobao':?'www.taobao.com'}? print?"字典值?:?%s"?%??tinydict.items() ?#?遍歷字典列表 for?key,values?in??tinydict.items():???? ????print?key,values
輸出結(jié)果:
字典值 : [('Google', 'www.google.com'), ('taobao', 'www.taobao.com'), ('Runoob', 'www.runoob.com')]
Google www.google.com
taobao www.taobao.comRunoob www.runoob.com
查看全部 -
一個(gè)*代表的是傳入一個(gè)元組(tuple),而兩個(gè)*代表的是傳入一個(gè)字典(dict)
查看全部 -
在Python的世界中,object是父子關(guān)系的頂端,所有的數(shù)據(jù)類型的父類都是它;type是類型實(shí)例關(guān)系的頂端,所有對(duì)象都是它的實(shí)例的。它們兩個(gè)的關(guān)系可以這樣描述:
object是一個(gè)type,object is and instance of type。即Object是type的一個(gè)實(shí)例。
查看全部 -
# super().__init__(). ——————繼承
# 在Python2中,super()的完整用法是super(自己類名,self)
# 在Python2中需要寫完整,而Python3中可以簡(jiǎn)寫為super()查看全部 -
private:私有的屬性,是以雙下劃線'__'開頭的屬性。eg1:__localtion
protected:受保護(hù)的
public:公共的
查看全部 -
def odde(x):
? ?return x%2==1
print(list(filter(odde,[1, 4, 6, 7, 9, 12, 17])))? #把迭代轉(zhuǎn)換list類型查看全部
舉報(bào)