Cpytron
Cpytron

Reputation: 13

How to fix a deleted module in Python 3.7.0

I have been practicing Python from a book and I think I accidentally deleted the datetime import.

I had used...

import datetime
datetime.datetime.now()

and kept getting an error. I found out that this was because I saved the file as datetime.py. I renamed the py file as showingdates.py and deleted the datetime.py I had saved in my folder in my documents tab. I also deleted the file called I think datetime.py in another folder that Python created called __pycache__.

So now when I run my program...

import datetime
datetime.datetime.now()

the return in Geany after execute is completely empty.

Did I delete the datetime module, and how do I fix this?

Upvotes: 0

Views: 277

Answers (1)

Arghya Saha
Arghya Saha

Reputation: 5713

Use this script Seems like you missed print statement.

import datetime
print(datetime.datetime.now())

Upvotes: 2

Related Questions