python筆記(1) 關(guān)于我們應(yīng)不應(yīng)該繼續(xù)學(xué)習(xí)python
更新時間:2012年10月24日 21:55:27 作者:
關(guān)于Python,如果你要學(xué)習(xí),建議大家查看一下網(wǎng)站:因為本人也是剛剛決定收集點零碎時間來學(xué)習(xí)下它,推薦可能并不是最好的
以前面試的時候會被問到,linux熟不熟呀?對于這種問題:我總會尷尬地回答,“額..了解一點”。
然而,我大學(xué)畢業(yè)的時候,連linux的虛擬機都沒裝過,更別提系統(tǒng)熟不熟悉了。雖然我了解一點這個系統(tǒng)可以完全通過命令來操作。后來工作了,有時候?qū)扅c代碼,svn提交上去,服務(wù)器是Linux的,自己也是在windows上跑跑客戶端。記得有個項目,要求用shell來啟動java程序,你知道那時候我是怎么做的嗎?把他們的shell拿來,問哪幾個地方要改的,然后改下要啟動java類的路徑。ok了,完全不去理解里面的意思。到最后又一次面試的時候,不得不坦白:不是太了解Linux命令。
有人可能會說:Linux命令沒什么難啊。花幾天時間就好了?,F(xiàn)在的我也會這么和完全不懂Linux的朋友這么說??墒侨绻也豢绯鰧W(xué)習(xí)命令的第一步。我未來的很長一段時間都不得不在面試的時候再一次尷尬。
回到正題,我們到底該不該去學(xué)習(xí)現(xiàn)在看來沒什么用而確實是不錯的東西呢?
我的回答是:如果你的確是有余力,并愿意向自己投資的話,我覺得是有必要的。
1,這種額外的學(xué)習(xí)會讓你的周末變得充實。
2,當(dāng)學(xué)習(xí)到一定程度的時候,會對事物有新的看法。
3,面試的時候,你多了一塊籌碼。
4,有一個理論:學(xué)習(xí)的越多,知道自己不知道的越多。(知識面越廣,你所看到的世界就越大?。?
就像情歌里唱的那樣:”我們一直都忘了要到一座橋,到對方心里瞧一瞧“,我想我們是不是也忘了去到一座橋,去別的地方瞧一瞧呢!呵呵
所以讓我們一起進入PYTHON世界吧!
python筆記(1)
關(guān)于Python,如果你要學(xué)習(xí),建議大家查看一下網(wǎng)站:(因為本人也是剛剛決定收集點零碎時間來學(xué)習(xí)下它,推薦可能并不是最好的)
http://book.huihoo.com/dive-into-python/5.4_zh-cn/html/toc/index.html 《Dive to python》
http://docs.python.org/
http://woodpecker.org.cn/
http://code.google.com/intl/zh-CN/edu/languages/google-python-class/introduction.html
剛接觸python我覺得很棒,因為安裝個軟件,馬上就能來個HelloWorld!
也許我們早就過了興奮的年紀,事實上,我是想說python絕對是讓你放輕松學(xué)習(xí)的語言。
1,函數(shù)聲明用 def
def buildConnectionString(params):
2,導(dǎo)入模塊:import
import odbchelper
在導(dǎo)入模塊時是python編譯器去自己的環(huán)境變量制定的路徑路去找這個模塊,如果要導(dǎo)入的模塊是自定義的路徑下,就必須把這個路徑先放進環(huán)境變量中去。
import sys
sys.path.append('/my/new/path')
3,if_else語句:(python通過縮進來控制代碼塊,代替了java中的“{}”)
if n > 1:
return n * fib(n - 1)
else:
print 'end of the line'
return 1
4,內(nèi)置數(shù)據(jù)類型List:
List li = ["a", "b", "mpilgrim", "z", "example"]
用“[]”包起來。
A.用for var in list,可以遍歷一個list。在遍歷的時候不要試著增加和刪除元素哦!
squares = [1, 4, 9, 16]
sum = 0
for num in squares:
sum += num
print sum ## 30
B.用in來判斷一個元素是否在list中:
list = ['larry', 'curly', 'moe']
if 'curly' in list:
print 'yay
C.list其他的方法:
list.append(elem) -- adds a single element to the end of the list. Common error: does not return the new list, just modifies the original.
list.insert(index, elem) -- inserts the element at the given index, shifting elements to the right.
list.extend(list2) adds the elements in list2 to the end of the list. Using + or += on a list is similar to using extend().
list.index(elem) -- searches for the given element from the start of the list and returns its index. Throws a ValueError if the element does not appear (use "in" to check without a ValueError).
list.remove(elem) -- searches for the first instance of the given element and removes it (throws ValueError if not present)
list.sort() -- sorts the list in place (does not return it). (The sorted() function shown below is preferred.)
list.reverse() -- reverses the list in place (does not return it)
list.pop(index) -- removes and returns the element at the given index. Returns the rightmost element if index is omitted (roughly the opposite of append()).
D.其他關(guān)于list的例子:
list = ['larry', 'curly', 'moe']
list.append('shemp') ## append elem at end
list.insert(0, 'xxx') ## insert elem at index 0
list.extend(['yyy', 'zzz']) ## add list of elems at end
print list ## ['xxx', 'larry', 'curly', 'moe', 'shemp', 'yyy', 'zzz']
print list.index('curly') ## 2
list.remove('curly') ## search and remove that element
list.pop(1) ## removes and returns 'larry'
print list ## ['xxx', 'moe', 'shemp', 'yyy', 'zzz']
本文純粹的目的是想讓更多的人去學(xué)習(xí)他們可能因各種借口拒絕學(xué)習(xí)的東西。
希望你能被我我的鼓動,而有所行動哦!
然而,我大學(xué)畢業(yè)的時候,連linux的虛擬機都沒裝過,更別提系統(tǒng)熟不熟悉了。雖然我了解一點這個系統(tǒng)可以完全通過命令來操作。后來工作了,有時候?qū)扅c代碼,svn提交上去,服務(wù)器是Linux的,自己也是在windows上跑跑客戶端。記得有個項目,要求用shell來啟動java程序,你知道那時候我是怎么做的嗎?把他們的shell拿來,問哪幾個地方要改的,然后改下要啟動java類的路徑。ok了,完全不去理解里面的意思。到最后又一次面試的時候,不得不坦白:不是太了解Linux命令。
有人可能會說:Linux命令沒什么難啊。花幾天時間就好了?,F(xiàn)在的我也會這么和完全不懂Linux的朋友這么說??墒侨绻也豢绯鰧W(xué)習(xí)命令的第一步。我未來的很長一段時間都不得不在面試的時候再一次尷尬。
回到正題,我們到底該不該去學(xué)習(xí)現(xiàn)在看來沒什么用而確實是不錯的東西呢?
我的回答是:如果你的確是有余力,并愿意向自己投資的話,我覺得是有必要的。
1,這種額外的學(xué)習(xí)會讓你的周末變得充實。
2,當(dāng)學(xué)習(xí)到一定程度的時候,會對事物有新的看法。
3,面試的時候,你多了一塊籌碼。
4,有一個理論:學(xué)習(xí)的越多,知道自己不知道的越多。(知識面越廣,你所看到的世界就越大?。?
就像情歌里唱的那樣:”我們一直都忘了要到一座橋,到對方心里瞧一瞧“,我想我們是不是也忘了去到一座橋,去別的地方瞧一瞧呢!呵呵
所以讓我們一起進入PYTHON世界吧!
python筆記(1)
關(guān)于Python,如果你要學(xué)習(xí),建議大家查看一下網(wǎng)站:(因為本人也是剛剛決定收集點零碎時間來學(xué)習(xí)下它,推薦可能并不是最好的)
http://book.huihoo.com/dive-into-python/5.4_zh-cn/html/toc/index.html 《Dive to python》
http://docs.python.org/
http://woodpecker.org.cn/
http://code.google.com/intl/zh-CN/edu/languages/google-python-class/introduction.html
剛接觸python我覺得很棒,因為安裝個軟件,馬上就能來個HelloWorld!
也許我們早就過了興奮的年紀,事實上,我是想說python絕對是讓你放輕松學(xué)習(xí)的語言。
1,函數(shù)聲明用 def
復(fù)制代碼 代碼如下:
def buildConnectionString(params):
2,導(dǎo)入模塊:import
復(fù)制代碼 代碼如下:
import odbchelper
在導(dǎo)入模塊時是python編譯器去自己的環(huán)境變量制定的路徑路去找這個模塊,如果要導(dǎo)入的模塊是自定義的路徑下,就必須把這個路徑先放進環(huán)境變量中去。
復(fù)制代碼 代碼如下:
import sys
sys.path.append('/my/new/path')
3,if_else語句:(python通過縮進來控制代碼塊,代替了java中的“{}”)
復(fù)制代碼 代碼如下:
if n > 1:
return n * fib(n - 1)
else:
print 'end of the line'
return 1
4,內(nèi)置數(shù)據(jù)類型List:
List li = ["a", "b", "mpilgrim", "z", "example"]
用“[]”包起來。
A.用for var in list,可以遍歷一個list。在遍歷的時候不要試著增加和刪除元素哦!
復(fù)制代碼 代碼如下:
squares = [1, 4, 9, 16]
sum = 0
for num in squares:
sum += num
print sum ## 30
B.用in來判斷一個元素是否在list中:
復(fù)制代碼 代碼如下:
list = ['larry', 'curly', 'moe']
if 'curly' in list:
print 'yay
C.list其他的方法:
復(fù)制代碼 代碼如下:
list.append(elem) -- adds a single element to the end of the list. Common error: does not return the new list, just modifies the original.
list.insert(index, elem) -- inserts the element at the given index, shifting elements to the right.
list.extend(list2) adds the elements in list2 to the end of the list. Using + or += on a list is similar to using extend().
list.index(elem) -- searches for the given element from the start of the list and returns its index. Throws a ValueError if the element does not appear (use "in" to check without a ValueError).
list.remove(elem) -- searches for the first instance of the given element and removes it (throws ValueError if not present)
list.sort() -- sorts the list in place (does not return it). (The sorted() function shown below is preferred.)
list.reverse() -- reverses the list in place (does not return it)
list.pop(index) -- removes and returns the element at the given index. Returns the rightmost element if index is omitted (roughly the opposite of append()).
D.其他關(guān)于list的例子:
復(fù)制代碼 代碼如下:
list = ['larry', 'curly', 'moe']
list.append('shemp') ## append elem at end
list.insert(0, 'xxx') ## insert elem at index 0
list.extend(['yyy', 'zzz']) ## add list of elems at end
print list ## ['xxx', 'larry', 'curly', 'moe', 'shemp', 'yyy', 'zzz']
print list.index('curly') ## 2
list.remove('curly') ## search and remove that element
list.pop(1) ## removes and returns 'larry'
print list ## ['xxx', 'moe', 'shemp', 'yyy', 'zzz']
本文純粹的目的是想讓更多的人去學(xué)習(xí)他們可能因各種借口拒絕學(xué)習(xí)的東西。
希望你能被我我的鼓動,而有所行動哦!
相關(guān)文章
Python數(shù)據(jù)可視化庫seaborn的使用總結(jié)
這篇文章主要介紹了Python數(shù)據(jù)可視化庫seaborn的使用總結(jié),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2019-01-01基于numpy.random.randn()與rand()的區(qū)別詳解
下面小編就為大家分享一篇基于numpy.random.randn()與rand()的區(qū)別詳解,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2018-04-04python3中bytes和string之間的互相轉(zhuǎn)換
這篇文章主要介紹了python3中bytes和string之間的互相轉(zhuǎn)換,文中給出了詳細的介紹和示例代碼,相信對大家具有一定的參考價值,有需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧。2017-02-02基于SpringBoot構(gòu)造器注入循環(huán)依賴及解決方式
這篇文章主要介紹了基于SpringBoot構(gòu)造器注入循環(huán)依賴及解決方式,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-04-04Python數(shù)據(jù)結(jié)構(gòu)之單鏈表詳解
這篇文章主要為大家詳細介紹了Python數(shù)據(jù)結(jié)構(gòu)之單鏈表的相關(guān)資料,具有一定的參考價值,感興趣的小伙伴們可以參考一下2017-09-09