如题,是在一个案例的for循环中,if执行了,按理elif不应该执行,但是结果依然执行了elif,不太理解,是忽略了什么吗
for msg in track:
print '-----------------------------------------------------'
print "the msg is {} \n".format(msg)
print '\n'
if isinstance(msg, midi.EndOfTrackEvent):
print "end of track!!pass!!"
continue
if msg.tick > 0:
print '##msg.tick > 0 !!!'
current_tick += msg.tick
print 'current_tick plus {} tick!'.format(msg.tick)
print current_tick
print msg.tick
if isinstance(msg, midi.NoteOnEvent) and msg.get_velocity() != 0:
if len(notes[msg.get_pitch()]) > 0 and len(notes[msg.get_pitch()][-1]) != 2:
if verbose:
print("double NoteOn encountered,delete the first")
print "the msg double note_on msg is {} \n".format(msg)
print "the pitch is {}".format(msg.get_pitch())
else:
notes[msg.get_pitch()] += [[current_tick]]
print notes[msg.get_pitch()]
print [[current_tick]]
print '#####this is noteonevent,,,the current_tick plus {} #####\n'.format(msg.get_pitch)
# print 'the cu'
elif isinstance(msg, midi.NoteOffEvent) or (isinstance(msg, midi.NoteOnEvent) and msg.get_velocity() == 0):
if len(notes[msg.get_pitch()][-1]) != 1:
if verbose:
print ("warning:skipping noteoff event with no corresponding noteon")
print (msg)
else:
notes[msg.get_pitch()][-1] += [current_tick]
print "the current_tick plus {} \n".format(notes[msg.get_pitch()][-1])
print notes[msg.get_pitch()][-1]
print [current_tick]
1、你忽略了要贴代码
2、你要相信,一般bug不是语言造成的,而是写代码的人~~~