[表示 : 全て 最新50 1-99 101- 2chのread.cgiへ]
Update time : 05/09 12:01 / Filesize : 38 KB / Number-of Response : 128
[このスレッドの書き込みを削除する]
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧] [類似スレッド一覧]


↑キャッシュ検索、類似スレ動作を修正しました、ご迷惑をお掛けしました

Python の宿題ここで答えます Part 2



83 名前:デフォルトの名無しさん mailto:sage [2010/01/01(金) 14:36:18 ]
#!/usr/bin/python
import sys, os, re

with open("setting.ini") as f:
    path = f.readline().rstrip("\r\n")
    regex = f.readline().rstrip("\r\n")
    repl = f.readline().rstrip("\r\n")

if os.path.isdir(path):
    for dirpath, dirnames, filenames in os.walk(path):
        for name in filenames:
            path = os.path.join(dirpath, name)
            contents = open(path).read()
            if re.search(regex, contents):
                open(path, "w").write(re.sub(regex, repl, contents))
else:
    sys.stderr.write("Error\n")






[ 続きを読む ] / [ 携帯版 ]

全部読む 次100 最新50 [ このスレをブックマーク! 携帯に送る ] 2chのread.cgiへ
[+板 最近立ったスレ&熱いスレ一覧 : +板 最近立ったスレ/記者別一覧](*・∀・)<38KB

read.cgi ver5.27 [feat.BBS2 +1.6] / e.0.2 (02/09/03) / eucaly.net products.
担当:undef