【问题标题】:IndentationError: unexpected indent in python 2.7IndentationError:python 2.7 中的意外缩进
【发布时间】:2020-03-03 20:47:52
【问题描述】:

我收到以下错误 IndentationError: 意外缩进

def send_daily(): '''每天发送的检查报告'''

    current_day = calendar.day_name[now_datetime().weekday()]
    enabled_reports = frappe.get_all('Auto Email Report',
            filters={'enabled': 1, 'frequency': ('in', ('Daily', 'Weekdays', 'Weekly'))})

    for report in enabled_reports:
            auto_email_report = frappe.get_doc('Auto Email Report', report.name)

            # if not correct weekday, skip
            if auto_email_report.frequency == "Weekdays":
                    if current_day in ("Saturday", "Sunday"):
                            continue
            elif auto_email_report.frequency == 'Weekly':
                    schedule.every().monday.at('10:00')
                            continue

我在线收到缩进错误: 如果 current_day 在(“星期六”,“星期日”): 继续 如何消除缩进错误?

【问题讨论】:

    标签: python-2.7


    【解决方案1】:

    continue in elif 放错了

    elif auto_email_report.frequency == 'Weekly':
                    schedule.every().monday.at('10:00')
                            continue
    

    应该是:

    elif auto_email_report.frequency == 'Weekly':
          schedule.every().monday.at('10:00')
          continue
    

    【讨论】:

      【解决方案2】:

      您没有收到来自:if current_day in ("Saturday", "Sunday"). 的错误

      您的错误在:schedule.every().monday.at('10:00')

      继续之后的错误行应该是:

      elif auto_email_report.frequency == 'Weekly':
        schedule.every().monday.at('10:00')
        continue
      

      【讨论】:

        猜你喜欢
        • 2018-03-26
        • 1970-01-01
        • 2021-12-18
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-03-11
        • 1970-01-01
        相关资源
        最近更新 更多