为什么python循环继续工作与其他编程语言不同

2024-04-19 11:47:26 发布

您现在位置:Python中文网/ 问答频道 /正文

在其他编程语言中,当循环中遇到continue时,它不会运行下面的代码,而是根据条件集执行下一个循环。你知道吗

然而在python中,它实际上不会在相同的精确值上触发continue多达3次,直到continue真正触发为止。有人能告诉我为什么会这样吗?你知道吗

功能

def get_section(self, address):
    for section in self.sections:
        section_base = section.image_base + section.VirtualAddress
        section_end = section_base + section.Misc_VirtualSize 
        print 'section_base= 0x%x' % section_base, ' section_end = 0x%x' % section_end
        print 'VirtualAdderss = 0x%x' % section.VirtualAddress, 'Misc_virtualSize = 0x%x' % section.Misc_VirtualSize
        if address < section_base or address >= section_end:
            print 'continuued'
            continue
        print 'not continuued'
        print 'Section name = ', section.section_name
        return section
    raise NotImplementedError()


这是日志

address = 0x4013f8

section_base= 0x401000  section_end = 0x5574e5
VirtualAdderss = 0x1000 Misc_virtualSize = 0x1564e5
not continuued
Section name =  text

address = 0x4013f8

section_base= 0x401000  section_end = 0x5574e5
VirtualAdderss = 0x1000 Misc_virtualSize = 0x1564e5
not continuued
Section name =  text

address = 0x55869c
section_base= 0x401000  section_end = 0x5574e5
VirtualAdderss = 0x1000 Misc_virtualSize = 0x1564e5
continuued

section_base= 0x558000  section_end = 0x5818ac
VirtualAdderss = 0x158000 Misc_virtualSize = 0x298ac
not continuued
Section name =  rdata


正如你所看到的,它没有持续两次,只是在第三次继续,我不明白为什么它不应该从第一次工作?你知道吗


Tags: nameselfbaseaddressnotsectionendmisc