Errors when importing datetime

Unresolved attribute reference ‘timedelta’ for class ‘datetime’ error.

Errors

Let’s analyze the errors of the genus:

Unresolved attribute reference ‘timedelta’ for class ‘datetime’ from datetime import datetime

They arise when modules for working with date and time are imported simultaneously in different ways. For example:

from datetime import datetime
import datetime, timedelta

We must choose one way and continue to adhere to it.

Also, an error will occur if the import is done in one of the ways below, and the use in another way is below.

import datetime, timedelta

If you import in this way, then you need to access the functions as follows:

datetimedatetimenow()datetimetimedelta(minutes=float(timer))

from datetime import datetime, timedelta

This method is more interesting, it allows you to shorten the spelling:

datetimenow() – timedelta(minutes=float(timer))

Similar Posts

Leave a Reply