Is there a conflict of libraries here?

Steve Gronicus at SGA.Ninja
Fri Nov 6 02:25:25 EST 2020


In my program, I have the following lines of code: 
 import random
 import re
 import time
 import datetime
 from datetime import timedelta
 from time import gmtime, strftime ##define strftime as time/date right
now
 import winsound as ws 
 import sys
These may or may not affect my new program code but here is the issue:
 
If I add the code:
 from datetime import datetime
these new lines work:
 dt = datetime.fromisoformat(ItemDateTime)
 dt_string = dt.strftime(' at %H:%M on %A %d %B %Y')
and will fail without that "datetime import datetime" line
 
however;
 
With that "datetime import datetime" line included,
all of the lines of code throughout the program that contain
"datetime.datetime" fail. 
These have been in use for over three years and there are at least a dozen
of them.
The error produced is:
 time1 = datetime.datetime.strptime(T1, date_format)
 AttributeError: type object 'datetime.datetime' has no attribute
'datetime'
 
How do I have my cake and eat it too?
Steve
 
 
 
Footnote:
Some mornings it just isn't worth chewing through the leather straps.
 


More information about the Python-list mailing list

AltStyle によって変換されたページ (->オリジナル) /