My IndentationError看起来如此无法解决。 http://pastebin.com/AFdnYcRc。Python:如何解决IndentationError
#!/usr/bin/env python
import os
import glob
import shutil
import mutagen
from sys import exit
musicdir = raw_input("What directory are the music files located in? : ")
musfile = glob.glob(musicdir + '/' + "*.mp3")
musfile1 = glob.glob(musicdir + '/' + "*.flac")
musfile.extend(musfile1)
newmusicdir = raw_input("What directory should the music files be organized into? : ")
done = False
while not done:
for m in musfile:
if musfile:
try:
musta = mutagen.File(m, easy=True)
mar = str(musta['artist'][0])
mal = str(musta['album'][0])
mti = str(musta['title'][0])
mtr = str(musta['tracknumber'][0])
os.makedirs(newmusicdir + '/' + mar + '/' + mal + '/')
except OSError:
pass
finally:
try:
if m.endswith('.mp3'):
os.rename(m,mtr + ' - ' + mar + ' - ' + mti + '.mp3')
m =mtr + ' - ' + mar + ' - ' + mti + '.mp3'
shutil.move(m,newmusicdir + '/' + mar + '/' + mal + '/')
elif m.endswith('.flac'):
os.rename(m,mtr + ' - ' + mar + ' - ' + mti + '.flac')
m = mtr + ' - ' + mar + ' - ' + mti + '.flac'
shutil.move(m,newmusicdir + '/' + mar + '/' + mal + '/')
elif not musfile:
print "Looks like we're done here. Please press <enter> to exit"
raw_input()
sys.exit(0)
发布确切的错误 - 它可能包含行号! – Kylotan 2011-05-05 20:37:13
也发布错误附近的代码。它可能会被不适当地缩进。最后,请在此处发布代码之前,用4个空格替换所有制表符。 – 2011-05-05 20:41:17
如果他们为您解决问题,您应该将正确答案标记为“已接受”。点击答案旁边的复选标记。 – Daenyth 2011-05-05 20:43:47