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!

Strange Problem 1

Status
Not open for further replies.

Wulf

Programmer
Nov 30, 2000
9
AT
Why does this work in the "Python Shell" but when I execute it in a script it doesn't work?

day = time.strftime('%d', time.gmtime(time.time()))

When I execute this in a script i get this error:

Traceback(most recent call last):
File "Myfile.py"
day = time.strftime('%d', time.gmtime(time.time()))
AttributeError: strftime

Seems a bit unlogical for me. Can someone help me?
 
your missing the "import module" clause, is this case,
you should import time:

# cat x
import time
day = time.strftime("%d", time.gmtime(time.time()))
print day
# python x
20

--
pkiller

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top