下記のコードを解決し、なぜos.makedirs
が機能しないのかを教えてください。 (インデントの世話をしないでください:彼らは右の元にちょうど私はこのサイト上のHTMLコーディングの上にグリップを取得していた)これはなぜ機能しないのですか? (os.makedirs)
import os,pprint,sys
while True:
print()
oq=input('Press the first directory: ')
print()
print()
ow=input('Press the next directory/name: ')
print()
p2=input('Continue with next directory? yes or no: ').lower()
if p2=='no':
break
print()
oe=input('Press the next directory/name: ')
print()
p3=input('Continue with next directory? yes or no: ').lower()
if p3=='no':
break
print()
oee=input('Press the next directory/name: ')
print()
p4=input('Continue with next directory? yes or no: ').lower()
if p4=='no':
break
print()
ot=input('Press the next directory/name: ')
print()
p5=input('Continue with next directory? yes or no: ').lower()
if p5=='no':
break
print()
oy=input('Press the next directory/name: ')
print()
p6=input('Continue with next directory? yes or no: ').lower()
if p6=='no':
break
print()
ou=input('Press the next directory/name: ')
print()
p7=input('Continue with next directory? yes or no: ').lower()
if p7=='no':
break
print()
if p2=='no':
os.makedirs(oq+'\\'+ow)
if p3=='no':
os.makedirs(oq+'\\'+ow+'\\'+oe)
if p4=='no':
os.makedirs(oq+'\\'+ow+'\\'+oe+'\\'+oee))
if p5=='no':
os.makedirs(oq+'\\'+ow+'\\'+oe+'\\'+oee+'\\'+ot)
if p6=='no':
os.makedirs(oq+'\\'+ow+'\\'+oe+'\\'+oee+'\\'+ot+'\\'+oy)
if p7=='no':
os.makedirs(oq+'\\'+ow+'\\'+oe+'\\'+oee+'\\'+ot+'\\'+oy+'\\'+ou)
ppp=input('Wannna continue???')
if ppp=='no':
sys.exit()
コードを読みやすいように書式設定したいと思うでしょう。そのような巨大な束にそれを貼り付けることは、あなたの質問に通常答える人々を、それによって右にスキップさせる可能性が高いでしょう。投稿のためのコード書式ヘルプセクションを見直し、編集/再投稿することをお勧めします。 – Chris
私はあなたが気にしないことを願っています...しかし、私はあなたのインデントを世話しました。私は、残りの部分との関係で各行を同じように保っていました。私がやったことをするには、コードをハイライトし、Ctrl-kを押します。 – zondo
「状況によっては動作しない」実際にそこに入るのを見るためにコードにデバッグメッセージを入れましたか? '\\\'をハードコーディングする代わりに 'os.path.join()'をパスに、 'os.sep'をセパレータとして使用してください。 – yedpodtrzitko