gpt4 book ai didi

Python:如何解决 IndentationError

转载 作者:太空宇宙 更新时间:2023-11-03 12:12:32 24 4
gpt4 key购买 nike

我的 IndentationError 似乎无法解决。 http://pastebin.com/AFdnYcRc .

#!/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)

最佳答案

你有一个 try block (从第 30 行开始)没有 except

关于Python:如何解决 IndentationError,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5903739/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com