elif ステートメントの Y と N の選択に問題があります。n を入力すると、n の elif 選択が正しく出力されますが、y を入力すると、elif 選択 y ではなく n 選択が出力されます。なぜこれを行っているのかわかりません。コードについて申し訳ありません。間違いが明らかになった場合、私はPythonが初めてです。
選択を確認しましたが、n または y の選択は保持されますが、y が入力されていても n が実行されます。
if os.path.exists('ExifOutput.txt'):
print "The file appears to already exist, would you like to overwrite it?"
Choice = raw_input("Y/N : ")
if not re.match("^[Y,y,N,n]*$", Choice):
print "Error! Only Choice Y or N allowed!"
elif len(Choice) > 1:
print "Error! Only 1 character allowed!"
elif not Choice:
print "No choice made"
elif Choice == 'N' or 'n':
print "Save the old file to a different directory and try again"
ExifTags()
elif Choice == 'Y' or 'y':
print "The file will be overwritten by a new one"
ExifRetrieval(listing, FileLocation)
print "Completed" + "\n"
else:
ExifRetrieval(listing, FileLocation)
print "Completed" + "\n"