[Tutor] A year's calendar to a text file? (original) (raw)
Dick Moores rdm at rcblue.com
Sun Jul 4 05:48:55 EDT 2004
- Previous message: [Tutor] A year's calendar to a text file?
- Next message: [Tutor] A year's calendar to a text file?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
I've got it, thanks to both Alan Gauld and Lloyd Kvam:
I found this function in the calendar module:
===================== calendar( year[, w[, l[c]]])
Returns a 3-column calendar for an entire year as a multi-line string. Optional parameters w, l, and c are for date column width, lines per week, and number of spaces between month columns, respectively. Depends on the first weekday as set by setfirstweekday(). The earliest year for which a calendar can be generated is platform-dependent. New in version 2.0.
So, """ import calendar
calendar.setfirstweekday(6) #sets first day of week to Sunday inp = calendar.calendar(2005)
outp = file("c2005.txt","w")
for line in inp: outp.write(line)
outp.close()
print "Year 2005 calendar created as c2005.txt" """
Thank you, tutors!
Dick Moores
- Previous message: [Tutor] A year's calendar to a text file?
- Next message: [Tutor] A year's calendar to a text file?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]