看板 Python 關於我們 聯絡資訊
小弟的寫法其實很普通 import glob files=glob.glob('./*') print files for file ind files: object=command.getoutput("grep -e 'ABC\|DEF'"+ file) print object 資料夾內有 txta txtb txtc 第一個print沒問題 可以print出txta txtb txtc 之後進入檔案搜尋 ABC DEF就跑不完了 內容應該沒有問題 ※ 引述《josefy (醉落~最弱)》之銘言: : 請問一個極為簡單的問題 : 在 ' '內的變數 要怎麼保持他的type : 例如commands.getoutput("grep 'ABC\|EFG' data") : data其實等於另一個檔案名稱 謝謝 : ※ 引述《josefy (醉落~最弱)》之銘言: : : 感謝!! : : 但請問一下 要如何加入 若是讀取到EFG 也要存入content : : 且 ABC EFG 兩列data 順序是跟raw data一樣? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 114.37.172.127 ※ 編輯: josefy 來自: 114.37.172.127 (07/16 22:38)