[問題] 將list快速寫入檔案的方式?
f = open('123.txt','r')
lines = f.readlines()
print len(lines) #2000000 lines
startindex = 30
endindex = 15000
outputfile = open('456.txt','w')
for i in range(startindex,endindex):
outputfile.write(lines[i])
outputfile.close()
想詢問除了這樣寫以外 有無更快的寫法
可以直接把string list寫到檔案內的寫法
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.195.222.114
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1456929799.A.310.html
→
03/02 23:36, , 1F
03/02 23:36, 1F
推
03/03 13:26, , 2F
03/03 13:26, 2F
討論串 (同標題文章)
以下文章回應了本文:
完整討論串 (本文為第 1 之 3 篇):
Python 近期熱門文章
PTT數位生活區 即時熱門文章