471,334 Members | 2,679 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,334 software developers and data experts.

formatting text

I am creating files in a directory and they need to be formatted by month/day format, but I haven't figured out how to format text so that it always shows four numbers.
Can anyone help me out?
Jun 14 '07 #1
4 1261
bartonc
6,596 Expert 4TB
I am creating files in a directory and they need to be formatted by month/day format, but I haven't figured out how to format text so that it always shows four numbers.
Can anyone help me out?
I'd use strftime() from the datetime module.
Jun 14 '07 #2
bvdet
2,851 Expert Mod 2GB
Expand|Select|Wrap|Line Numbers
  1. import datetime
  2.  
  3. seed_date = datetime.date(2007,01,01)
  4. td = datetime.timedelta(1)
  5. fileList = [''.join((seed_date+td*i).strftime('%m%d'))+'.txt' for i in range(365)]
Jun 14 '07 #3
Expand|Select|Wrap|Line Numbers
  1. import datetime
  2.  
  3. seed_date = datetime.date(2007,01,01)
  4. td = datetime.timedelta(1)
  5. fileList = [''.join((seed_date+td*i).strftime('%m%d'))+'.txt' for i in range(365)]




Thanks, I get it now.
Jun 15 '07 #4
I am creating files in a directory and they need to be formatted by month/day format, but I haven't figured out how to format text so that it always shows four numbers.
Can anyone help me out?
thanks i also got it..
Aug 5 '07 #5

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Bradley | last post: by
7 posts views Thread by BBFrost | last post: by
14 posts views Thread by Scott M. | last post: by
3 posts views Thread by michael sorens | last post: by
3 posts views Thread by =?Utf-8?B?b24tbGluZSBqb3VybmFsIGVkaXRvcg==?= | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.