顯示具有 Python 標籤的文章。 顯示所有文章
顯示具有 Python 標籤的文章。 顯示所有文章

10.02.2008

Python, the functions I want to use - string

先記一下要用到的function:
"Parrot" 就是 ['P','a','r','r','o','t'] 的意思。
所以,
"Parrot"[ 0] 是 'P'
"Parrot"[-1] 是 't'

string.find(string,sub) : sub 在 string 中的位置,如果沒有,return -1。


剩下就是 create folder,create file , write file 的function了...

如果作完了再加上 UI。 -- wxPython.

10.01.2008

os.walk in Python

os.walk 是很方便(有趣)的 function。
像 os.walk('c:\\') 會自動 walk all the folders in c:\

return 三個 value : path, 這個path 中的 folder, file,例如:

C:\MyProj 下面有 dir1, dir2 這兩個 folder 和 file3, file4 這兩個 file。
os.walk('c:\\myproj') 會 給出以下的 tunple:

c:\MyProj, [dir1,dir2], [file3,file4]
...

很方便吧。不用寫 recursive function 去一一的找..

9.30.2008

IDE for Python : SPE

因為 Vincent 很難得的決定了要 follow google 的腳步,立定志向要用 Python,最為他身為 經理 之外的一項程式技能,剛好我又在 try python ide (ref : R40eUbuntu),所以在這裡紀錄一下:

需要 python 2.5 -- 一般 python for windows 會有 activesate 可以選擇,但是我還是裝 official site 的版本,目前是 2.5.2。裝完後,開啟command 輸入 python 看看可不可以正確 invoke python。還有版本是不是正確的 2.5.2 版,如果沒有,確認有把 python.exe 的 folder (Python25) 加到 path 中。


裝 wxPython,我是裝 2.8,如果剛剛的 Python 2.5 有沒有正確安裝,就會出現要你確認 Python25 所在目錄的提示,如果沒有,就 OK。


最後裝 SPE,我是裝 SPE-0.8.4.c-wx2.6.1.0-no_setup ,這個版本是不用 exe 檔安裝的,就 unzip 後,不要改 folder 名 (_spe) 就可以了。我是把 _spe copy 到 C:\ 下。


然後就到 _spe 下 double click "spe.py" 就可以 launch SPE 了

嗯,當初 SPE,Eric 二選一,但是 在 windows 下 Eric 裝起來太龐大了,要裝 Qt library,還要裝 MinGW,所以,還是選了比較簡單安裝的 SPE,而且功能好像差不多。