python中elif老是出错_python为什么会存在if执行了依然会执行elif的情况?
如題,是在一個案例的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]
總結
以上是生活随笔為你收集整理的python中elif老是出错_python为什么会存在if执行了依然会执行elif的情况?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python websocket ser
- 下一篇: websocket python爬虫_p