The Artima Developer Community
Sponsored Link

Python Answers Forum
Date in Python

1 reply on 1 page. Most recent reply: Apr 13, 2004 11:18 AM by Girts Kalnins

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Senthoorkumaran Punniamoorthy

Posts: 335
Nickname: senthoor
Registered: Mar, 2002

Date in Python Posted: Feb 27, 2004 5:42 PM
Reply to this message Reply
Advertisement
>>>s='1978-12-11'
>>>s[:4],s[6:8],s[8:]

now I wanted to create a date object with it. so I imported the datetime object using

>>>import datetime

then I tried to create a date object

I am get this error

>>> x=date(int(s[:4]),int(s[5:7]),int(s[8:]))

Traceback (most recent call last):
File "<pyshell#6>", line 1, in -toplevel-
x=date(int(s[:4]),int(s[5:7]),int(s[8:]))
NameError: name 'date' is not defined

Any help?


Girts Kalnins

Posts: 23
Nickname: smejmoon
Registered: May, 2003

Re: Date in Python Posted: Apr 13, 2004 11:18 AM
Reply to this message Reply

>>> import datetime
>>> e = datetime.date(1,2,3)
>>> e.ctime()
'Sat Feb 3 00:00:00 0001'

Read more about python modules:
http://www.python.org/doc/current/tut/node8.html

Flat View: This topic has 1 reply on 1 page
Topic: getting an exe to execute from a website Previous Topic   Next Topic Topic: Active document with Photoshop 5.5

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use