python筆記(1)-關於我們應不應該繼續學習


關於我們應不應該繼續學習

  以前面試的時候會被問到,linux熟不熟呀?對於這種問題:我總會尷尬地回答,“額..了解一點”。

  然而,我大學畢業的時候,連linux的虛擬機都沒裝過,更別提系統熟不熟悉了。雖然我了解一點這個系統可以完全通過命令來操作。后來工作了,有時候寫點代碼,svn提交上去,服務器是Linux的,自己也是在windows上跑跑客戶端。記得有個項目,要求用shell來啟動java程序,你知道那時候我是怎么做的嗎?把他們的shell拿來,問哪幾個地方要改的,然后改下要啟動java類的路徑。ok了,完全不去理解里面的意思。到最后又一次面試的時候,不得不坦白:不是太了解Linux命令。

  有人可能會說:Linux命令沒什么難啊。花幾天時間就好了。現在的我也會這么和完全不懂Linux的朋友這么說。可是如果我不跨出學習命令的第一步。我未來的很長一段時間都不得不在面試的時候再一次尷尬。

  回到正題,我們到底該不該去學習現在看來沒什么用而確實是不錯的東西呢?

  我的回答是:如果你的確是有余力,並願意向自己投資的話,我覺得是有必要的。

  1,這種額外的學習會讓你的周末變得充實。

  2,當學習到一定程度的時候,會對事物有新的看法。

  3,面試的時候,你多了一塊籌碼。

  4,有一個理論:學習的越多,知道自己不知道的越多。(知識面越廣,你所看到的世界就越大!)

 

  就像情歌里唱的那樣:”我們一直都忘了要到一座橋,到對方心里瞧一瞧“,我想我們是不是也忘了去到一座橋,去別的地方瞧一瞧呢!呵呵

 

所以讓我們一起進入PYTHON世界吧!

 

python筆記(1)

關於Python,如果你要學習,建議大家查看一下網站:(因為本人也是剛剛決定收集點零碎時間來學習下它,推薦可能並不是最好的)

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絕對是讓你放輕松學習的語言。

1,函數聲明用 def

def buildConnectionString(params):

2,導入模塊:import

import odbchelper


在導入模塊時是python編譯器去自己的環境變量制定的路徑路去找這個模塊,如果要導入的模塊是自定義的路徑下,就必須把這個路徑先放進環境變量中去。

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,內置數據類型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.其他關於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']

 

本文純粹的目的是想讓更多的人去學習他們可能因各種借口拒絕學習的東西。
希望你能被我我的鼓動,而有所行動哦!

----------------------------------------------------------------------

努力不一定成功,但不努力肯定不會成功。
共勉。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM