python筆記(1) 關(guān)于我們應(yīng)不應(yīng)該繼續(xù)學(xué)習(xí)python
更新時(shí)間:2012年10月24日 21:55:27 作者:
關(guān)于Python,如果你要學(xué)習(xí),建議大家查看一下網(wǎng)站:因?yàn)楸救艘彩莿倓倹Q定收集點(diǎn)零碎時(shí)間來學(xué)習(xí)下它,推薦可能并不是最好的
以前面試的時(shí)候會(huì)被問到,linux熟不熟呀?對(duì)于這種問題:我總會(huì)尷尬地回答,“額..了解一點(diǎn)”。
然而,我大學(xué)畢業(yè)的時(shí)候,連linux的虛擬機(jī)都沒裝過,更別提系統(tǒng)熟不熟悉了。雖然我了解一點(diǎn)這個(gè)系統(tǒng)可以完全通過命令來操作。后來工作了,有時(shí)候?qū)扅c(diǎn)代碼,svn提交上去,服務(wù)器是Linux的,自己也是在windows上跑跑客戶端。記得有個(gè)項(xiàng)目,要求用shell來啟動(dòng)java程序,你知道那時(shí)候我是怎么做的嗎?把他們的shell拿來,問哪幾個(gè)地方要改的,然后改下要啟動(dòng)java類的路徑。ok了,完全不去理解里面的意思。到最后又一次面試的時(shí)候,不得不坦白:不是太了解Linux命令。
有人可能會(huì)說:Linux命令沒什么難啊?;◣滋鞎r(shí)間就好了。現(xiàn)在的我也會(huì)這么和完全不懂Linux的朋友這么說??墒侨绻也豢绯鰧W(xué)習(xí)命令的第一步。我未來的很長(zhǎng)一段時(shí)間都不得不在面試的時(shí)候再一次尷尬。
回到正題,我們到底該不該去學(xué)習(xí)現(xiàn)在看來沒什么用而確實(shí)是不錯(cuò)的東西呢?
我的回答是:如果你的確是有余力,并愿意向自己投資的話,我覺得是有必要的。
1,這種額外的學(xué)習(xí)會(huì)讓你的周末變得充實(shí)。
2,當(dāng)學(xué)習(xí)到一定程度的時(shí)候,會(huì)對(duì)事物有新的看法。
3,面試的時(shí)候,你多了一塊籌碼。
4,有一個(gè)理論:學(xué)習(xí)的越多,知道自己不知道的越多。(知識(shí)面越廣,你所看到的世界就越大?。?
就像情歌里唱的那樣:”我們一直都忘了要到一座橋,到對(duì)方心里瞧一瞧“,我想我們是不是也忘了去到一座橋,去別的地方瞧一瞧呢!呵呵
所以讓我們一起進(jìn)入PYTHON世界吧!
python筆記(1)
關(guān)于Python,如果你要學(xué)習(xí),建議大家查看一下網(wǎng)站:(因?yàn)楸救艘彩莿倓倹Q定收集點(diǎn)零碎時(shí)間來學(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我覺得很棒,因?yàn)榘惭b個(gè)軟件,馬上就能來個(gè)HelloWorld!
也許我們?cè)缇瓦^了興奮的年紀(jì),事實(shí)上,我是想說python絕對(duì)是讓你放輕松學(xué)習(xí)的語言。
1,函數(shù)聲明用 def
def buildConnectionString(params):
2,導(dǎo)入模塊:import
import odbchelper
在導(dǎo)入模塊時(shí)是python編譯器去自己的環(huán)境變量制定的路徑路去找這個(gè)模塊,如果要導(dǎo)入的模塊是自定義的路徑下,就必須把這個(gè)路徑先放進(jìn)環(huán)境變量中去。
import sys
sys.path.append('/my/new/path')
3,if_else語句:(python通過縮進(jìn)來控制代碼塊,代替了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,可以遍歷一個(gè)list。在遍歷的時(shí)候不要試著增加和刪除元素哦!
squares = [1, 4, 9, 16]
sum = 0
for num in squares:
sum += num
print sum ## 30
B.用in來判斷一個(gè)元素是否在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í)的東西。
希望你能被我我的鼓動(dòng),而有所行動(dòng)哦!
然而,我大學(xué)畢業(yè)的時(shí)候,連linux的虛擬機(jī)都沒裝過,更別提系統(tǒng)熟不熟悉了。雖然我了解一點(diǎn)這個(gè)系統(tǒng)可以完全通過命令來操作。后來工作了,有時(shí)候?qū)扅c(diǎn)代碼,svn提交上去,服務(wù)器是Linux的,自己也是在windows上跑跑客戶端。記得有個(gè)項(xiàng)目,要求用shell來啟動(dòng)java程序,你知道那時(shí)候我是怎么做的嗎?把他們的shell拿來,問哪幾個(gè)地方要改的,然后改下要啟動(dòng)java類的路徑。ok了,完全不去理解里面的意思。到最后又一次面試的時(shí)候,不得不坦白:不是太了解Linux命令。
有人可能會(huì)說:Linux命令沒什么難啊?;◣滋鞎r(shí)間就好了。現(xiàn)在的我也會(huì)這么和完全不懂Linux的朋友這么說??墒侨绻也豢绯鰧W(xué)習(xí)命令的第一步。我未來的很長(zhǎng)一段時(shí)間都不得不在面試的時(shí)候再一次尷尬。
回到正題,我們到底該不該去學(xué)習(xí)現(xiàn)在看來沒什么用而確實(shí)是不錯(cuò)的東西呢?
我的回答是:如果你的確是有余力,并愿意向自己投資的話,我覺得是有必要的。
1,這種額外的學(xué)習(xí)會(huì)讓你的周末變得充實(shí)。
2,當(dāng)學(xué)習(xí)到一定程度的時(shí)候,會(huì)對(duì)事物有新的看法。
3,面試的時(shí)候,你多了一塊籌碼。
4,有一個(gè)理論:學(xué)習(xí)的越多,知道自己不知道的越多。(知識(shí)面越廣,你所看到的世界就越大?。?
就像情歌里唱的那樣:”我們一直都忘了要到一座橋,到對(duì)方心里瞧一瞧“,我想我們是不是也忘了去到一座橋,去別的地方瞧一瞧呢!呵呵
所以讓我們一起進(jìn)入PYTHON世界吧!
python筆記(1)
關(guān)于Python,如果你要學(xué)習(xí),建議大家查看一下網(wǎng)站:(因?yàn)楸救艘彩莿倓倹Q定收集點(diǎn)零碎時(shí)間來學(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我覺得很棒,因?yàn)榘惭b個(gè)軟件,馬上就能來個(gè)HelloWorld!
也許我們?cè)缇瓦^了興奮的年紀(jì),事實(shí)上,我是想說python絕對(duì)是讓你放輕松學(xué)習(xí)的語言。
1,函數(shù)聲明用 def
復(fù)制代碼 代碼如下:
def buildConnectionString(params):
2,導(dǎo)入模塊:import
復(fù)制代碼 代碼如下:
import odbchelper
在導(dǎo)入模塊時(shí)是python編譯器去自己的環(huán)境變量制定的路徑路去找這個(gè)模塊,如果要導(dǎo)入的模塊是自定義的路徑下,就必須把這個(gè)路徑先放進(jìn)環(huán)境變量中去。
復(fù)制代碼 代碼如下:
import sys
sys.path.append('/my/new/path')
3,if_else語句:(python通過縮進(jìn)來控制代碼塊,代替了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,可以遍歷一個(gè)list。在遍歷的時(shí)候不要試著增加和刪除元素哦!
復(fù)制代碼 代碼如下:
squares = [1, 4, 9, 16]
sum = 0
for num in squares:
sum += num
print sum ## 30
B.用in來判斷一個(gè)元素是否在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í)的東西。
希望你能被我我的鼓動(dòng),而有所行動(dòng)哦!
您可能感興趣的文章:
- Python學(xué)習(xí)思維導(dǎo)圖(必看篇)
- python簡(jiǎn)單線程和協(xié)程學(xué)習(xí)心得(分享)
- 學(xué)習(xí)python的幾條建議分享
- wxpython學(xué)習(xí)筆記(推薦查看)
- Python學(xué)習(xí)資料
- wxpython 學(xué)習(xí)筆記 第一天
- 簡(jiǎn)明 Python 基礎(chǔ)學(xué)習(xí)教程
- 學(xué)習(xí)python (1)
- python學(xué)習(xí)之面向?qū)ο蟆救腴T初級(jí)篇】
- 最近Python有點(diǎn)火? 給你7個(gè)學(xué)習(xí)它的理由!
相關(guān)文章
Django1.11配合uni-app發(fā)起微信支付的實(shí)現(xiàn)
這篇文章主要介紹了Django1.11配合uni-app發(fā)起微信支付的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2019-10-10
Python實(shí)現(xiàn)Appium端口檢測(cè)與釋放的實(shí)現(xiàn)
這篇文章主要介紹了Python實(shí)現(xiàn)Appium端口檢測(cè)與釋放的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12
使用python腳本自動(dòng)創(chuàng)建pip.ini配置文件代碼實(shí)例
這篇文章主要介紹了使用python腳本自動(dòng)創(chuàng)建pip.ini配置文件代碼實(shí)例,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-09-09
python計(jì)算無向圖節(jié)點(diǎn)度的實(shí)例代碼
今天小編就為大家分享一篇python計(jì)算無向圖節(jié)點(diǎn)度的實(shí)例代碼,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2019-11-11
Python基于機(jī)器學(xué)習(xí)方法實(shí)現(xiàn)的電影推薦系統(tǒng)實(shí)例詳解
這篇文章主要介紹了Python基于機(jī)器學(xué)習(xí)方法實(shí)現(xiàn)的電影推薦系統(tǒng),本文給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-06-06
Python基于ImageAI實(shí)現(xiàn)圖像識(shí)別詳解
ImageAI是一個(gè)面向計(jì)算機(jī)視覺編程的Python庫(kù),支持最先進(jìn)的機(jī)器學(xué)習(xí)算法。本文將利用ImageAI實(shí)現(xiàn)圖像識(shí)別功能,感興趣的小伙伴可以跟隨小編一起學(xué)習(xí)一下2023-02-02
Python實(shí)現(xiàn)火柴人的設(shè)計(jì)與實(shí)現(xiàn)
火柴人(Stick Figure)是一種極簡(jiǎn)風(fēng)格的圖形,通常由簡(jiǎn)單的線段和圓圈組成,卻能生動(dòng)地表達(dá)人物的姿態(tài)和動(dòng)作,本文旨在介紹如何使用Python實(shí)現(xiàn)火柴人的設(shè)計(jì)與繪制,通過編程的方式,讓讀者了解火柴人背后的基本原理和實(shí)現(xiàn)方法,需要的朋友可以參考下2024-10-10

