Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Library problems in converting date string to epoch time

Status
Not open for further replies.

raindogs

Programmer
Nov 23, 2005
27
US
I'm a little new to Python and am stuck in a deeply awkward situation. I'm working at a client site where I have no control over what is installed on their server and no ability to do any sort of upgrade. They're running what appears to be a very stripped down version of Python 2.1, which is causing some library issues. All I need to do is take a date string and convert it to an epoch time, which most documentation says will require the time.strptime function. Unfortunately, the following piece of code:

try:
strptime = time.strptime
except AttributeError:
print "nope you don't have it"
from strptime import c

Results in the following error:

ImportError: No module named strptime

Is there another way around this? Is there any way I can get the library I need from another install and just call it locally? I'm really stuck here.

Thanks,
Alex
 

raindogs,

Did you import the time module? e.g.:

Code:
import time

 
its true you have to write Import time at the top of your code then i think the codes will work
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top