看板 [ Python ]
討論串[問題] 請問一下讀檔的問題
共 8 篇文章
首頁
上一頁
1
2
下一頁
尾頁

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者chy1013m1 (alex)時間18年前 (2007/04/01 15:28), 編輯資訊
0
0
0
內容預覽:
haha, list comprehension, very nice! that is how python should have been used. --. alex.c. --. 發信站: 批踢踢實業坊(ptt.cc). ◆ From: 74.99.96.111.

推噓0(0推 0噓 0→)留言0則,0人參與, 最新作者yungyuc (酷狗喵千代)時間18年前 (2007/03/16 11:27), 編輯資訊
0
0
0
內容預覽:
[deleted][deleted]. 來個短的. import re. words = set([ word.lower() for word in. re.findall(r"\w+", open("rf.dat").read()) ]). print len(words), "words in

推噓1(1推 0噓 0→)留言1則,0人參與, 最新作者huggie (huggie)時間18年前 (2007/03/08 18:47), 編輯資訊
0
0
0
內容預覽:
^^^^^^^^^^^^. 這個 call 檔案太大時會出問題. 因為他會把檔案全部讀進記憶體成為一個 list. 才開始 loop. 建議用 for line in i:. 或者直接 for line in open('text.txt'):. 乾淨爽快, for loop 結束自動 close(

推噓1(1推 0噓 0→)留言1則,0人參與, 最新作者ibmibmibm (殺.人.鬼)時間18年前 (2007/03/05 02:53), 編輯資訊
0
0
0
內容預覽:
引述《wawawa (哇哇哇○( ̄﹏ ̄)○)》之銘言:. 是我的話就這樣寫. #!/usr/bin/python. import re. result = set(). pattern = re.compile(r'(\w+)'). f = open('text.txt', 'r'). for
(還有12個字)

推噓3(3推 0噓 0→)留言3則,0人參與, 最新作者wawawa (哇哇哇○( ̄﹏ ̄)○)時間18年前 (2007/03/04 16:20), 編輯資訊
0
0
0
內容預覽:
回完你的信才發現這邊也有XD. 我順便將我使用re的筆記po上來好了...有錯請不要鞭太大力:p. re.compile.findall. --. txt = """div class=pexplain>123</div>. div class=pexplain>456</div>""". for
(還有707個字)
首頁
上一頁
1
2
下一頁
尾頁