看板 Python 關於我們 聯絡資訊
※ 引述《halaGG (halaGG)》之銘言: : ※ 引述《huggie (huggie)》之銘言: : : fd = open('test.txt') : : print fd.read() : : fd.close() : : 放同一個資料夾就好 open裡的參數也可以指定位置 : : open('c:\\test.txt') 等 : 歐...請原諒我不一次請教完>"< : 照著您說的 有讀到該死的那一大串atgc了... : 可是還是不會.count它們...囧> 其實你要的功能可以直接在 command line 裡一行搞定: python -c "print open('test.txt').read().count('AG')" 注意,以上是在 command line 執行的指令喔,不必寫到程式檔裡面 :) -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 220.139.135.240
huggie:哇!我第一次知道Python可以像Perl一樣這樣用 06/05 11:17
huggie:大推 06/05 11:17
Killertcell:大推!!!! 06/05 22:09