Jump to content
ben20

python

Recommended Posts

ma joc pe codecademy si am ajuns pe la date time etc, care stiti si am asta :


from datetime import datetime
now = datetime.now()
year = now.year
month = now.month
day = now.day
hour = now.hour
minute = now.minute
second = now.second
print str(month) + "/" + str(day) + "/" + str(year)
print str(hour) + ":" + str(minute) + ":" + str(second)

Am instalat pe ubuntu python Idle 3.2 bag codu asta si nimic..oare ce sa fie ? vroiam sa ma mai joc cu el sa-mi afiseze in mai multe feluri.

Link to comment
Share on other sites

Sintaxa pentru print a fost schimbata in Python3

Old: print "The answer is", 2*2

New: print("The answer is", 2*2)

Old: print x, # Trailing comma suppresses newline

New: print(x, end=" ") # Appends a space instead of a newline

Old: print # Prints a newline

New: print() # You must call the function!

Old: print >>sys.stderr, "fatal error"

New: print("fatal error", file=sys.stderr)

Old: print (x, y) # prints repr((x, y))

New: print((x, y)) # Not the same as print(x, y)!

Pentru cele mai bune rezultare ar trebui sa downloadezi Python 2.7 ca sa nu ai probleme cand urmaresti tutorialele acelea.

Daca ai oferi mai multe detalii cum ar fi , ce eroare primesti in IDLE ne-ar fi mult mai usor sa te indrumam.

Link to comment
Share on other sites

Pai nimic asta e..defapt problema :)

Python 2.7.3 (default, Aug  1 2012, 05:16:07) 
[GCC 4.6.3] on linux2
Type "copyright", "credits" or "license()" for more information.
==== No Subprocess ====
>>> from datetime import datetime
now = datetime.now()
year = now.year
month = now.month
day = now.day
hour = now.hour
minute = now.minute
second = now.second
print str(month) + "/" + str(day) + "/" + str(year)
print str(hour) + ":" + str(minute) + ":" + str(second)
>>>
>>>
>>>

Am bagat 2.7 si la fel..:-?

Gata am rezolvat aparent trebuie save module.:P my bad

Edited by ben20
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...