简体   繁体   English

如何解决indentationError:意外缩进?

[英]How to resolved indentationError: unexpected indent?

How do I rectify this error "unexpected indent" in python? 如何在python中纠正此错误“意外缩进”?

from fast_rcnn.config import cfg
from nms.cpu_nms import cpu_nms

def nms(dets, thresh, force_cpu=False):
    """Dispatch to either CPU or GPU NMS implementations."""

    if (dets.shape[0]) == 0:
     return []

    return cpu_nms(dets, thresh)

Assuming this is not a copy and paste error when copying into SE, you need to change the indentation for your first return: 假设这不是复制到SE时的复制和粘贴错误,则需要为首次返回更改缩进:

from fast_rcnn.config import cfg
from nms.cpu_nms import cpu_nms

def nms(dets, thresh, force_cpu=False):
    """Dispatch to either CPU or GPU NMS implementations."""

    if (dets.shape[0]) == 0:
        # Note the changed indentation here
        return []

    return cpu_nms(dets, thresh)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM