Pycharm Scheduling: function object has no Attribute "Day" / cannot import time

Viewed 27

I'm using Python inside Pycharm, and wanting to scheduling code to run to open a workbook and save every day at a specified time. The function I've written to open and save the workbook has been working properly, but I'm now running in to two issues.

  1. I cannot Import time, it's greying out and I'm not sure why
  2. I'm receiving error "AttributeError: 'function' object has no attribute 'day'", and I'm not sure why. error occurs at ".day" within schedule function

import schedule import time

def Date_Table():
    from openpyxl import load_workbook
    wb = load_workbook(r'file path')
    wb.save(r'file path')

schedule.every.day.at("1:00").do(Date_Table)
1 Answers

I reviewed the functions in the "schedule" package. You just need to correct some syntax. Instead of:

schedule.every.day.at("1:00").do(Date_Table)

you probably want:

schedule.every().day.at("01:00").do(Date_Table)

Note the parentheses in the function call.

Hope that helps.

Regards.

Related