3 つのことを行う Python スクリプトを作成したいと思います。
現在のコード:
import os, time
from os.path import walk
mydictionary = {"</i>":"</em>"}
for (path, dirs, files) in os.walk(raw_input('Copy and Paste Course Directory Here: ')):
for f in files:
if f.endswith('.html'):
filepath = os.path.join(path,f)
s = open(filepath).read()
for k, v in mydictionary.iteritems(): terms for a dictionary file and replace
s = s.replace(k, v)
f = open(filepath, 'w')
f.write(s)
f.close()
今、私はパート 1 と 3 を持っています。パート 2 だけが必要です。
パート 2 では、ユーザーが指定するディレクトリに html ファイルのみが存在することを確認する必要があります。それ以外の場合、スクリプトはユーザーに正しいフォルダー ディレクトリ (html ファイルを含む) を入力するように求めます。
ありがとう