看板 Python 關於我們 聯絡資訊
問題如下, 如果有一個檔案,內容為要插入特定字串的行數。 100 200 300 400 . . .etc 接下來要在另一個檔案的特定行數插入特定字串。 xxxxxxxxxxxxxxxxxx '100 -> insert string . . . xxxxxxxxxxxxxxxxxx '200 -> insert string . . . xxxxxxxxxxxxxxxxxx '300 -> insert string 有高手可以分享解法嗎,謝謝 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 50.206.17.2 ※ 文章網址: https://www.ptt.cc/bbs/Python/M.1553247588.A.7EE.html
froce: 最笨的方法就讀進list,改掉想要的元素,丟回原檔 03/22 18:24
lemon651: 讀進list再插效率不好,不如開一個新的list全部掃一遍 03/22 20:22
lemon651: 重插 03/22 20:22