我有一个完整的mp3文件路径列表。
print ("/home/jds/Music/Other Songs/Supernatural.mp3" in mp3_files) #prints True
for f in mp3_files:
if '/home/jds/Music/Other Songs/Supernatural.mp3' == f :
print "Gotcha"
mp3 = eyed3.load( f )
if mp3.tag is None: #check if mp3 file has id3
print f + " is None"
mp3_files.remove( f ) #no id3, remove from list!!
上面的代码打印“True”和一些文件路径。此特定文件没有id3,因此if语句应该为true,此文件路径以后应该不再存在。不知何故,它仍然在列表中,并导致以后崩溃。
好吧,首先我检查一下该文件路径是否在列表中,然后输出为“True”,因此它就在那里。然后我遍历列表中的每个文件路径,如果到达该文件路径,它应该打印“Gotcha”。但是,它没有!怎么了?!
编辑:
我在for循环中的if语句之后删除了部分以测试某些内容,现在我得到输出“Gotcha”。
print ("/home/jds/Music/Other Songs/Supernatural.mp3" in mp3_files) #prints True
for f in mp3_files:
if '/home/jds/Music/Other Songs/Supernatural.mp3' == f :
print "Gotcha"