看板 Python 關於我們 聯絡資訊
※ 引述《shawkid (EDGE)》之銘言: : 各位大大 : 想請教一各字串問題 : 檔案 a.txt 內容 : main.php : s1.php : s2.php : a1.php : a2.php : . : . : . : 檔案 b.txt 內容 : 2008/8/14 1700 main.php : 2008/8/14 1800 s1.php : 2008/8/14 1801 aa.php : 2008/8/14 1823 a2.php : . : . : . : 請問該如何以 a.txt為 樣板 去搜尋 b.txt 檔案內的文字呢?? : [即 2008/8/14 1801 aa.php 是不合法的字串] : 請問有無參考資料或語法 可供實做呢 : 感謝了 雖然我知道這是不對的 但既然在休息中,就直接給你答案 :p $ python -c "print [line.split()[-1].strip() for line in open('b.txt') if line.split()[-1].strip() not in [item.strip() for item in open('a.txt')]]" ['aa.php'] -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 164.107.170.191
cobrasgo:好人卡(遞) 08/15 23:24
yungyuc:哼,沒在怕的啦 08/16 01:39