Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
datetime module question
#3
from calendar import Calendar
from datetime import date
year, month, *_ = date.today().timetuple()
cal = Calendar()
dates = [dt.strftime('%a %d %B %Y') for dt in cal.itermonthdates(year, month) if dt.month == month]
print(dates)
Output:
['Sun 01 October 2023', 'Mon 02 October 2023', 'Tue 03 October 2023', 'Wed 04 October 2023', 'Thu 05 October 2023', 'Fri 06 October 2023', 'Sat 07 October 2023', 'Sun 08 October 2023', 'Mon 09 October 2023', 'Tue 10 October 2023', 'Wed 11 October 2023', 'Thu 12 October 2023', 'Fri 13 October 2023', 'Sat 14 October 2023', 'Sun 15 October 2023', 'Mon 16 October 2023', 'Tue 17 October 2023', 'Wed 18 October 2023', 'Thu 19 October 2023', 'Fri 20 October 2023', 'Sat 21 October 2023', 'Sun 22 October 2023', 'Mon 23 October 2023', 'Tue 24 October 2023', 'Wed 25 October 2023', 'Thu 26 October 2023', 'Fri 27 October 2023', 'Sat 28 October 2023', 'Sun 29 October 2023', 'Mon 30 October 2023', 'Tue 31 October 2023']
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Messages In This Thread
datetime module question - by jacksfrustration - Oct-12-2023, 11:01 AM
RE: datetime module question - by menator01 - Oct-12-2023, 12:43 PM
RE: datetime module question - by jacksfrustration - Oct-12-2023, 02:37 PM
RE: datetime module question - by buran - Oct-12-2023, 01:39 PM
RE: datetime module question - by jacksfrustration - Oct-12-2023, 02:27 PM
RE: datetime module question - by menator01 - Oct-12-2023, 04:38 PM
RE: datetime module question - by deanhystad - Oct-12-2023, 06:31 PM
RE: datetime module question - by buran - Oct-12-2023, 07:10 PM
RE: datetime module question - by agmoraojr - Jan-12-2024, 01:24 AM
RE: datetime module question - by deanhystad - Jan-12-2024, 04:54 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Module not found question sighhhh12 0 1,643 Sep-09-2022, 05:43 AM
Last Post: sighhhh12
  Question on subprocess module. knoxvilles_joker 3 2,872 Apr-11-2021, 12:51 AM
Last Post: knoxvilles_joker
  keyboard module question DPaul 0 2,253 Mar-23-2021, 04:22 PM
Last Post: DPaul
  TypeError: unsupported operand type(s) for -: 'datetime.datetime' and 'str' findbikash 2 9,935 Sep-18-2019, 08:32 AM
Last Post: buran
  Module googletrans 2.4.0 Question hlhp 0 2,698 Jun-17-2019, 03:50 PM
Last Post: hlhp
  Question about the Random Module Exsul 1 2,081 Mar-13-2019, 02:06 AM
Last Post: ichabod801
  Problem with datetime module PierreSoulier 3 9,477 Jul-24-2018, 11:03 AM
Last Post: perfringo
  Python Module Question ATXpython 9 9,736 Oct-09-2016, 12:59 AM
Last Post: ATXpython

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020