Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

just a poke at python

Name: Newb oreo 2012-08-03 20:40

Hello, im new to python and programming in general. I have a small Dates problem that is getting me a little stuck in my progress. I currently am using the Codecademy approach to sort of reduce the fear of learning this foreign language.

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

I am able to generate the current date and time and I understand how to concatenate the strings and I somewhat understand the str()'s role in the problem. My issue and I apologize as my english is subpar but merjing the two dates together in a one line output but also keeping the proper format has been difficult. For example I must have the output produce a result in the form of mm/dd/yyyy hh:mm:ss which I can do individually however I run into issues when trying to merge them. if that makes no sense I will try to rewrite the body of this message again. Thank you for your comments!

Name: Anonymous 2012-08-03 20:58

First, usetags to render as x = 1.

Second, look for python tutorials.

Third, in advance, use
print '{}/{}/{} {}:{}:{}'.format(m,d,y,H,M,S)
as a general output formatting, or
print now.strftime('%m/%d/%y %H:%M:%S')
which is datetime-specific formatting.

Name: Anonymous 2012-08-03 21:00

[b][code][/b] x = 1 [b][/code][/b] tags ¬¬

Name: Anonymous 2012-08-03 21:00

4 get

Name: Anonymous 2012-08-03 21:54

>using legacy languages instead of javascript
summer is never going to end

Name: Anonymous 2012-08-03 21:57

>>5
[aa]back to /b/, please.[/a]

Name: Anonymous 2012-08-03 21:58

>>5
back to /b/, please.

Name: Anonymous 2012-08-03 22:12

>>7
>implying your not a huge faggot

Name: Anonymous 2012-08-03 22:16

9 get

Name: sage 2012-08-03 22:17

sage

Name: Anonymous 2012-08-03 22:18

>>5
>>8

>Implying greentext work's here and your not shittier troll

back to /b/ please

Name: Anonymous 2012-08-03 22:36

`
>Python


ishygddt

Name: Anonymous 2012-08-04 4:12

print '{}/{}/{} {}:{}:{}'.format(m,d,y,H,M,S)
This is ugly compared to how a real programmer would do it:
print "%4i-%02i-%02iT%02i:%02i:%02i" % (y, m, d, H, M, S)

Don't change these.
Name: Email:
Entire Thread Thread List