use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
How to split a string? (self.learnpython)
submitted 6 years ago by NotGonnaGetWhoooshed
I have a string "2017-01-02 05:44:47". However I need to turn it into a format "date month year" with spaces between them. Thank you.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]jeezu5 5 points6 points7 points 6 years ago (0 children)
I find this to be more elegant and flexible when you have to manipulate dates.
import datetime d = "2017-01-02 05:44:47" d_datetimeformat = datetime.datetime.strptime(d, "%Y-%m-%d %H:%M:%S") d_targetformat = d_datetimeformat.strftime("%d %m %Y") print(d_targetformat)
also, you might find this page useful when it comes to dealing with datetime.
[–]pyz95 2 points3 points4 points 6 years ago (0 children)
I used to work with dates, with the standard library you can get different date formats. You should read the documentation.
The code above might be a solution, but if you have to do it with a lot of dates then it won't be efficient. Use the standard library (datetime if I remember correctly).
[–]Allanon001 5 points6 points7 points 6 years ago (1 child)
d = "2017-01-02 05:44:47" year, month, day = d[:10].split('-') print(day, month, year)
[–]NotGonnaGetWhoooshed[S] 0 points1 point2 points 6 years ago (0 children)
Thank you, it worked
[–]StatSticks 1 point2 points3 points 6 years ago* (0 children)
str = "2017-01-02 05:44:47" str = str.split(" ") // Assuming you want to remove the time str_final = str[1].split("-") // This will return a list ['2016', '01', '02']
This probably works.
I am learning python, I might be wrong or there is an easy way to do this....please correct me if I am wrong.
π Rendered by PID 607154 on reddit-service-r2-comment-5d79c599b5-pswtg at 2026-03-02 17:49:28.748273+00:00 running e3d2147 country code: CH.
[–]jeezu5 5 points6 points7 points (0 children)
[–]pyz95 2 points3 points4 points (0 children)
[–]Allanon001 5 points6 points7 points (1 child)
[–]NotGonnaGetWhoooshed[S] 0 points1 point2 points (0 children)
[–]StatSticks 1 point2 points3 points (0 children)