当前位置:   article > 正文

Python 日历库calendar常用函数_python中calendar函数

python中calendar函数

module calendar

  1. >>> import calendar
  2. >>> dir(calendar)
  3. ['Calendar', 'EPOCH', 'FRIDAY', 'February', 'HTMLCalendar', 'IllegalMonthError',
  4. 'IllegalWeekdayError', 'January', 'LocaleHTMLCalendar', 'LocaleTextCalendar', 'MONDAY',
  5. 'SATURDAY', 'SUNDAY', 'THURSDAY', 'TUESDAY', 'TextCalendar', 'WEDNESDAY', '_EPOCH_ORD',
  6. '__all__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__',
  7. '__package__', '__spec__', '_colwidth', '_locale', '_localized_day', '_localized_month',
  8. '_monthlen', '_nextmonth', '_prevmonth', '_spacing', 'c', 'calendar', 'datetime',
  9. 'day_abbr', 'day_name', 'different_locale', 'error', 'firstweekday', 'format',
  10. 'formatstring', 'isleap', 'leapdays', 'main', 'mdays', 'month', 'month_abbr', 'month_name',
  11. 'monthcalendar', 'monthrange', 'prcal', 'prmonth', 'prweek', 'repeat', 'setfirstweekday',
  12. 'sys', 'timegm', 'week', 'weekday', 'weekheader']
  13. >>> calendar.__all__
  14. ['IllegalMonthError', 'IllegalWeekdayError', 'setfirstweekday', 'firstweekday', 'isleap',
  15. 'leapdays', 'weekday', 'monthrange', 'monthcalendar', 'prmonth', 'month', 'prcal',
  16. 'calendar', 'timegm', 'month_name', 'month_abbr', 'day_name', 'day_abbr', 'Calendar',
  17. 'TextCalendar', 'HTMLCalendar', 'LocaleTextCalendar', 'LocaleHTMLCalendar', 'weekheader']
  18. >>> [i for i in dir(calendar) if i[0]>='a']
  19. ['c', 'calendar', 'datetime', 'day_abbr', 'day_name', 'different_locale', 'error',
  20. 'firstweekday', 'format', 'formatstring', 'isleap', 'leapdays', 'main', 'mdays', 'month',
  21. 'month_abbr', 'month_name', 'monthcalendar', 'monthrange', 'prcal', 'prmonth', 'prweek',
  22. 'repeat', 'setfirstweekday', 'sys', 'timegm', 'week', 'weekday', 'weekheader']
  23. >>>
  1. >>> help(calendar)
  2. Help on module calendar:
  3. NAME
  4. calendar - Calendar printing functions
  5. MODULE REFERENCE
  6. https://docs.python.org/3.8/library/calendar
  7. The following documentation is automatically generated from the Python
  8. source files. It may be incomplete, incorrect or include features that
  9. are considered implementation detail and may vary between Python
  10. implementations. When in doubt, consult the module reference at the
  11. location listed above.
  12. DESCRIPTION
  13. Note when comparing these calendars to the ones printed by cal(1): By
  14. default, these calendars have Monday as the first day of the week, and
  15. Sunday as the last (the European convention). Use setfirstweekday() to
  16. set the first day of the week (0=Monday, 6=Sunday).
  17. CLASSES
  18. builtins.ValueError(builtins.Exception)
  19. IllegalMonthError
  20. IllegalWeekdayError
  21. builtins.object
  22. Calendar
  23. HTMLCalendar
  24. LocaleHTMLCalendar
  25. TextCalendar
  26. LocaleTextCalendar
  27. class Calendar(builtins.object)
  28. | Calendar(firstweekday=0)
  29. |
  30. | Base calendar class. This class doesn't do any formatting. It simply
  31. | provides data to subclasses.
  32. |
  33. | Methods defined here:
  34. |
  35. | __init__(self, firstweekday=0)
  36. | Initialize self. See help(type(self)) for accurate signature.
  37. |
  38. | getfirstweekday(self)
  39. |
  40. | itermonthdates(self, year, month)
  41. | Return an iterator for one month. The iterator will yield datetime.date
  42. | values and will always iterate through complete weeks, so it will yield
  43. | dates outside the specified month.
  44. |
  45. | itermonthdays(self, year, month)
  46. | Like itermonthdates(), but will yield day numbers. For days outside
  47. | the specified month the day number is 0.
  48. |
  49. | itermonthdays2(self, year, month)
  50. | Like itermonthdates(), but will yield (day number, weekday number)
  51. | tuples. For days outside the specified month the day number is 0.
  52. |
  53. | itermonthdays3(self, year, month)
  54. | Like itermonthdates(), but will yield (year, month, day) tuples. Can be
  55. | used for dates outside of datetime.date range.
  56. |
  57. | itermonthdays4(self, year, month)
  58. | Like itermonthdates(), but will yield (year, month, day, day_of_week) tuples.
  59. | Can be used for dates outside of datetime.date range.
  60. |
  61. | iterweekdays(self)
  62. | Return an iterator for one week of weekday numbers starting with the
  63. | configured first one.
  64. |
  65. | monthdatescalendar(self, year, month)
  66. | Return a matrix (list of lists) representing a month's calendar.
  67. | Each row represents a week; week entries are datetime.date values.
  68. |
  69. | monthdays2calendar(self, year, month)
  70. | Return a matrix representing a month's calendar.
  71. | Each row represents a week; week entries are
  72. | (day number, weekday number) tuples. Day numbers outside this month
  73. | are zero.
  74. |
  75. | monthdayscalendar(self, year, month)
  76. | Return a matrix representing a month's calendar.
  77. | Each row represents a week; days outside this month are zero.
  78. |
  79. | setfirstweekday(self, firstweekday)
  80. |
  81. | yeardatescalendar(self, year, width=3)
  82. | Return the data for the specified year ready for formatting. The return
  83. | value is a list of month rows. Each month row contains up to width months.
  84. | Each month contains between 4 and 6 weeks and each week contains 1-7
  85. | days. Days are datetime.date objects.
  86. |
  87. | yeardays2calendar(self, year, width=3)
  88. | Return the data for the specified year ready for formatting (similar to
  89. | yeardatescalendar()). Entries in the week lists are
  90. | (day number, weekday number) tuples. Day numbers outside this month are
  91. | zero.
  92. |
  93. | yeardayscalendar(self, year, width=3)
  94. | Return the data for the specified year ready for formatting (similar to
  95. | yeardatescalendar()). Entries in the week lists are day numbers.
  96. | Day numbers outside this month are zero.
  97. |
  98. | ----------------------------------------------------------------------
  99. | Data descriptors defined here:
  100. |
  101. | __dict__
  102. | dictionary for instance variables (if defined)
  103. |
  104. | __weakref__
  105. | list of weak references to the object (if defined)
  106. |
  107. | firstweekday
  108. class HTMLCalendar(Calendar)
  109. | HTMLCalendar(firstweekday=0)
  110. |
  111. | This calendar returns complete HTML pages.
  112. |
  113. | Method resolution order:
  114. | HTMLCalendar
  115. | Calendar
  116. | builtins.object
  117. |
  118. | Methods defined here:
  119. |
  120. | formatday(self, day, weekday)
  121. | Return a day as a table cell.
  122. |
  123. | formatmonth(self, theyear, themonth, withyear=True)
  124. | Return a formatted month as a table.
  125. |
  126. | formatmonthname(self, theyear, themonth, withyear=True)
  127. | Return a month name as a table row.
  128. |
  129. | formatweek(self, theweek)
  130. | Return a complete week as a table row.
  131. |
  132. | formatweekday(self, day)
  133. | Return a weekday name as a table header.
  134. |
  135. | formatweekheader(self)
  136. | Return a header for a week as a table row.
  137. |
  138. | formatyear(self, theyear, width=3)
  139. | Return a formatted year as a table of tables.
  140. |
  141. | formatyearpage(self, theyear, width=3, css='calendar.css', encoding=None)
  142. | Return a formatted year as a complete HTML page.
  143. |
  144. | ----------------------------------------------------------------------
  145. | Data and other attributes defined here:
  146. |
  147. | cssclass_month = 'month'
  148. |
  149. | cssclass_month_head = 'month'
  150. |
  151. | cssclass_noday = 'noday'
  152. |
  153. | cssclass_year = 'year'
  154. |
  155. | cssclass_year_head = 'year'
  156. |
  157. | cssclasses = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
  158. |
  159. | cssclasses_weekday_head = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', '...
  160. |
  161. | ----------------------------------------------------------------------
  162. | Methods inherited from Calendar:
  163. |
  164. | __init__(self, firstweekday=0)
  165. | Initialize self. See help(type(self)) for accurate signature.
  166. |
  167. | getfirstweekday(self)
  168. |
  169. | itermonthdates(self, year, month)
  170. | Return an iterator for one month. The iterator will yield datetime.date
  171. | values and will always iterate through complete weeks, so it will yield
  172. | dates outside the specified month.
  173. |
  174. | itermonthdays(self, year, month)
  175. | Like itermonthdates(), but will yield day numbers. For days outside
  176. | the specified month the day number is 0.
  177. |
  178. | itermonthdays2(self, year, month)
  179. | Like itermonthdates(), but will yield (day number, weekday number)
  180. | tuples. For days outside the specified month the day number is 0.
  181. |
  182. | itermonthdays3(self, year, month)
  183. | Like itermonthdates(), but will yield (year, month, day) tuples. Can be
  184. | used for dates outside of datetime.date range.
  185. |
  186. | itermonthdays4(self, year, month)
  187. | Like itermonthdates(), but will yield (year, month, day, day_of_week) tuples.
  188. | Can be used for dates outside of datetime.date range.
  189. |
  190. | iterweekdays(self)
  191. | Return an iterator for one week of weekday numbers starting with the
  192. | configured first one.
  193. |
  194. | monthdatescalendar(self, year, month)
  195. | Return a matrix (list of lists) representing a month's calendar.
  196. | Each row represents a week; week entries are datetime.date values.
  197. |
  198. | monthdays2calendar(self, year, month)
  199. | Return a matrix representing a month's calendar.
  200. | Each row represents a week; week entries are
  201. | (day number, weekday number) tuples. Day numbers outside this month
  202. | are zero.
  203. |
  204. | monthdayscalendar(self, year, month)
  205. | Return a matrix representing a month's calendar.
  206. | Each row represents a week; days outside this month are zero.
  207. |
  208. | setfirstweekday(self, firstweekday)
  209. |
  210. | yeardatescalendar(self, year, width=3)
  211. | Return the data for the specified year ready for formatting. The return
  212. | value is a list of month rows. Each month row contains up to width months.
  213. | Each month contains between 4 and 6 weeks and each week contains 1-7
  214. | days. Days are datetime.date objects.
  215. |
  216. | yeardays2calendar(self, year, width=3)
  217. | Return the data for the specified year ready for formatting (similar to
  218. | yeardatescalendar()). Entries in the week lists are
  219. | (day number, weekday number) tuples. Day numbers outside this month are
  220. | zero.
  221. |
  222. | yeardayscalendar(self, year, width=3)
  223. | Return the data for the specified year ready for formatting (similar to
  224. | yeardatescalendar()). Entries in the week lists are day numbers.
  225. | Day numbers outside this month are zero.
  226. |
  227. | ----------------------------------------------------------------------
  228. | Data descriptors inherited from Calendar:
  229. |
  230. | __dict__
  231. | dictionary for instance variables (if defined)
  232. |
  233. | __weakref__
  234. | list of weak references to the object (if defined)
  235. |
  236. | firstweekday
  237. class IllegalMonthError(builtins.ValueError)
  238. | IllegalMonthError(month)
  239. |
  240. | Inappropriate argument value (of correct type).
  241. |
  242. | Method resolution order:
  243. | IllegalMonthError
  244. | builtins.ValueError
  245. | builtins.Exception
  246. | builtins.BaseException
  247. | builtins.object
  248. |
  249. | Methods defined here:
  250. |
  251. | __init__(self, month)
  252. | Initialize self. See help(type(self)) for accurate signature.
  253. |
  254. | __str__(self)
  255. | Return str(self).
  256. |
  257. | ----------------------------------------------------------------------
  258. | Data descriptors defined here:
  259. |
  260. | __weakref__
  261. | list of weak references to the object (if defined)
  262. |
  263. | ----------------------------------------------------------------------
  264. | Static methods inherited from builtins.ValueError:
  265. |
  266. | __new__(*args, **kwargs) from builtins.type
  267. | Create and return a new object. See help(type) for accurate signature.
  268. |
  269. | ----------------------------------------------------------------------
  270. | Methods inherited from builtins.BaseException:
  271. |
  272. | __delattr__(self, name, /)
  273. | Implement delattr(self, name).
  274. |
  275. | __getattribute__(self, name, /)
  276. | Return getattr(self, name).
  277. |
  278. | __reduce__(...)
  279. | Helper for pickle.
  280. |
  281. | __repr__(self, /)
  282. | Return repr(self).
  283. |
  284. | __setattr__(self, name, value, /)
  285. | Implement setattr(self, name, value).
  286. |
  287. | __setstate__(...)
  288. |
  289. | with_traceback(...)
  290. | Exception.with_traceback(tb) --
  291. | set self.__traceback__ to tb and return self.
  292. |
  293. | ----------------------------------------------------------------------
  294. | Data descriptors inherited from builtins.BaseException:
  295. |
  296. | __cause__
  297. | exception cause
  298. |
  299. | __context__
  300. | exception context
  301. |
  302. | __dict__
  303. |
  304. | __suppress_context__
  305. |
  306. | __traceback__
  307. |
  308. | args
  309. class IllegalWeekdayError(builtins.ValueError)
  310. | IllegalWeekdayError(weekday)
  311. |
  312. | Inappropriate argument value (of correct type).
  313. |
  314. | Method resolution order:
  315. | IllegalWeekdayError
  316. | builtins.ValueError
  317. | builtins.Exception
  318. | builtins.BaseException
  319. | builtins.object
  320. |
  321. | Methods defined here:
  322. |
  323. | __init__(self, weekday)
  324. | Initialize self. See help(type(self)) for accurate signature.
  325. |
  326. | __str__(self)
  327. | Return str(self).
  328. |
  329. | ----------------------------------------------------------------------
  330. | Data descriptors defined here:
  331. |
  332. | __weakref__
  333. | list of weak references to the object (if defined)
  334. |
  335. | ----------------------------------------------------------------------
  336. | Static methods inherited from builtins.ValueError:
  337. |
  338. | __new__(*args, **kwargs) from builtins.type
  339. | Create and return a new object. See help(type) for accurate signature.
  340. |
  341. | ----------------------------------------------------------------------
  342. | Methods inherited from builtins.BaseException:
  343. |
  344. | __delattr__(self, name, /)
  345. | Implement delattr(self, name).
  346. |
  347. | __getattribute__(self, name, /)
  348. | Return getattr(self, name).
  349. |
  350. | __reduce__(...)
  351. | Helper for pickle.
  352. |
  353. | __repr__(self, /)
  354. | Return repr(self).
  355. |
  356. | __setattr__(self, name, value, /)
  357. | Implement setattr(self, name, value).
  358. |
  359. | __setstate__(...)
  360. |
  361. | with_traceback(...)
  362. | Exception.with_traceback(tb) --
  363. | set self.__traceback__ to tb and return self.
  364. |
  365. | ----------------------------------------------------------------------
  366. | Data descriptors inherited from builtins.BaseException:
  367. |
  368. | __cause__
  369. | exception cause
  370. |
  371. | __context__
  372. | exception context
  373. |
  374. | __dict__
  375. |
  376. | __suppress_context__
  377. |
  378. | __traceback__
  379. |
  380. | args
  381. class LocaleHTMLCalendar(HTMLCalendar)
  382. | LocaleHTMLCalendar(firstweekday=0, locale=None)
  383. |
  384. | This class can be passed a locale name in the constructor and will return
  385. | month and weekday names in the specified locale. If this locale includes
  386. | an encoding all strings containing month and weekday names will be returned
  387. | as unicode.
  388. |
  389. | Method resolution order:
  390. | LocaleHTMLCalendar
  391. | HTMLCalendar
  392. | Calendar
  393. | builtins.object
  394. |
  395. | Methods defined here:
  396. |
  397. | __init__(self, firstweekday=0, locale=None)
  398. | Initialize self. See help(type(self)) for accurate signature.
  399. |
  400. | formatmonthname(self, theyear, themonth, withyear=True)
  401. | Return a month name as a table row.
  402. |
  403. | formatweekday(self, day)
  404. | Return a weekday name as a table header.
  405. |
  406. | ----------------------------------------------------------------------
  407. | Methods inherited from HTMLCalendar:
  408. |
  409. | formatday(self, day, weekday)
  410. | Return a day as a table cell.
  411. |
  412. | formatmonth(self, theyear, themonth, withyear=True)
  413. | Return a formatted month as a table.
  414. |
  415. | formatweek(self, theweek)
  416. | Return a complete week as a table row.
  417. |
  418. | formatweekheader(self)
  419. | Return a header for a week as a table row.
  420. |
  421. | formatyear(self, theyear, width=3)
  422. | Return a formatted year as a table of tables.
  423. |
  424. | formatyearpage(self, theyear, width=3, css='calendar.css', encoding=None)
  425. | Return a formatted year as a complete HTML page.
  426. |
  427. | ----------------------------------------------------------------------
  428. | Data and other attributes inherited from HTMLCalendar:
  429. |
  430. | cssclass_month = 'month'
  431. |
  432. | cssclass_month_head = 'month'
  433. |
  434. | cssclass_noday = 'noday'
  435. |
  436. | cssclass_year = 'year'
  437. |
  438. | cssclass_year_head = 'year'
  439. |
  440. | cssclasses = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', 'sun']
  441. |
  442. | cssclasses_weekday_head = ['mon', 'tue', 'wed', 'thu', 'fri', 'sat', '...
  443. |
  444. | ----------------------------------------------------------------------
  445. | Methods inherited from Calendar:
  446. |
  447. | getfirstweekday(self)
  448. |
  449. | itermonthdates(self, year, month)
  450. | Return an iterator for one month. The iterator will yield datetime.date
  451. | values and will always iterate through complete weeks, so it will yield
  452. | dates outside the specified month.
  453. |
  454. | itermonthdays(self, year, month)
  455. | Like itermonthdates(), but will yield day numbers. For days outside
  456. | the specified month the day number is 0.
  457. |
  458. | itermonthdays2(self, year, month)
  459. | Like itermonthdates(), but will yield (day number, weekday number)
  460. | tuples. For days outside the specified month the day number is 0.
  461. |
  462. | itermonthdays3(self, year, month)
  463. | Like itermonthdates(), but will yield (year, month, day) tuples. Can be
  464. | used for dates outside of datetime.date range.
  465. |
  466. | itermonthdays4(self, year, month)
  467. | Like itermonthdates(), but will yield (year, month, day, day_of_week) tuples.
  468. | Can be used for dates outside of datetime.date range.
  469. |
  470. | iterweekdays(self)
  471. | Return an iterator for one week of weekday numbers starting with the
  472. | configured first one.
  473. |
  474. | monthdatescalendar(self, year, month)
  475. | Return a matrix (list of lists) representing a month's calendar.
  476. | Each row represents a week; week entries are datetime.date values.
  477. |
  478. | monthdays2calendar(self, year, month)
  479. | Return a matrix representing a month's calendar.
  480. | Each row represents a week; week entries are
  481. | (day number, weekday number) tuples. Day numbers outside this month
  482. | are zero.
  483. |
  484. | monthdayscalendar(self, year, month)
  485. | Return a matrix representing a month's calendar.
  486. | Each row represents a week; days outside this month are zero.
  487. |
  488. | setfirstweekday(self, firstweekday)
  489. |
  490. | yeardatescalendar(self, year, width=3)
  491. | Return the data for the specified year ready for formatting. The return
  492. | value is a list of month rows. Each month row contains up to width months.
  493. | Each month contains between 4 and 6 weeks and each week contains 1-7
  494. | days. Days are datetime.date objects.
  495. |
  496. | yeardays2calendar(self, year, width=3)
  497. | Return the data for the specified year ready for formatting (similar to
  498. | yeardatescalendar()). Entries in the week lists are
  499. | (day number, weekday number) tuples. Day numbers outside this month are
  500. | zero.
  501. |
  502. | yeardayscalendar(self, year, width=3)
  503. | Return the data for the specified year ready for formatting (similar to
  504. | yeardatescalendar()). Entries in the week lists are day numbers.
  505. | Day numbers outside this month are zero.
  506. |
  507. | ----------------------------------------------------------------------
  508. | Data descriptors inherited from Calendar:
  509. |
  510. | __dict__
  511. | dictionary for instance variables (if defined)
  512. |
  513. | __weakref__
  514. | list of weak references to the object (if defined)
  515. |
  516. | firstweekday
  517. class LocaleTextCalendar(TextCalendar)
  518. | LocaleTextCalendar(firstweekday=0, locale=None)
  519. |
  520. | This class can be passed a locale name in the constructor and will return
  521. | month and weekday names in the specified locale. If this locale includes
  522. | an encoding all strings containing month and weekday names will be returned
  523. | as unicode.
  524. |
  525. | Method resolution order:
  526. | LocaleTextCalendar
  527. | TextCalendar
  528. | Calendar
  529. | builtins.object
  530. |
  531. | Methods defined here:
  532. |
  533. | __init__(self, firstweekday=0, locale=None)
  534. | Initialize self. See help(type(self)) for accurate signature.
  535. |
  536. | formatmonthname(self, theyear, themonth, width, withyear=True)
  537. | Return a formatted month name.
  538. |
  539. | formatweekday(self, day, width)
  540. | Returns a formatted week day name.
  541. |
  542. | ----------------------------------------------------------------------
  543. | Methods inherited from TextCalendar:
  544. |
  545. | formatday(self, day, weekday, width)
  546. | Returns a formatted day.
  547. |
  548. | formatmonth(self, theyear, themonth, w=0, l=0)
  549. | Return a month's calendar string (multi-line).
  550. |
  551. | formatweek(self, theweek, width)
  552. | Returns a single week in a string (no newline).
  553. |
  554. | formatweekheader(self, width)
  555. | Return a header for a week.
  556. |
  557. | formatyear(self, theyear, w=2, l=1, c=6, m=3)
  558. | Returns a year's calendar as a multi-line string.
  559. |
  560. | prmonth(self, theyear, themonth, w=0, l=0)
  561. | Print a month's calendar.
  562. |
  563. | prweek(self, theweek, width)
  564. | Print a single week (no newline).
  565. |
  566. | pryear(self, theyear, w=0, l=0, c=6, m=3)
  567. | Print a year's calendar.
  568. |
  569. | ----------------------------------------------------------------------
  570. | Methods inherited from Calendar:
  571. |
  572. | getfirstweekday(self)
  573. |
  574. | itermonthdates(self, year, month)
  575. | Return an iterator for one month. The iterator will yield datetime.date
  576. | values and will always iterate through complete weeks, so it will yield
  577. | dates outside the specified month.
  578. |
  579. | itermonthdays(self, year, month)
  580. | Like itermonthdates(), but will yield day numbers. For days outside
  581. | the specified month the day number is 0.
  582. |
  583. | itermonthdays2(self, year, month)
  584. | Like itermonthdates(), but will yield (day number, weekday number)
  585. | tuples. For days outside the specified month the day number is 0.
  586. |
  587. | itermonthdays3(self, year, month)
  588. | Like itermonthdates(), but will yield (year, month, day) tuples. Can be
  589. | used for dates outside of datetime.date range.
  590. |
  591. | itermonthdays4(self, year, month)
  592. | Like itermonthdates(), but will yield (year, month, day, day_of_week) tuples.
  593. | Can be used for dates outside of datetime.date range.
  594. |
  595. | iterweekdays(self)
  596. | Return an iterator for one week of weekday numbers starting with the
  597. | configured first one.
  598. |
  599. | monthdatescalendar(self, year, month)
  600. | Return a matrix (list of lists) representing a month's calendar.
  601. | Each row represents a week; week entries are datetime.date values.
  602. |
  603. | monthdays2calendar(self, year, month)
  604. | Return a matrix representing a month's calendar.
  605. | Each row represents a week; week entries are
  606. | (day number, weekday number) tuples. Day numbers outside this month
  607. | are zero.
  608. |
  609. | monthdayscalendar(self, year, month)
  610. | Return a matrix representing a month's calendar.
  611. | Each row represents a week; days outside this month are zero.
  612. |
  613. | setfirstweekday(self, firstweekday)
  614. |
  615. | yeardatescalendar(self, year, width=3)
  616. | Return the data for the specified year ready for formatting. The return
  617. | value is a list of month rows. Each month row contains up to width months.
  618. | Each month contains between 4 and 6 weeks and each week contains 1-7
  619. | days. Days are datetime.date objects.
  620. |
  621. | yeardays2calendar(self, year, width=3)
  622. | Return the data for the specified year ready for formatting (similar to
  623. | yeardatescalendar()). Entries in the week lists are
  624. | (day number, weekday number) tuples. Day numbers outside this month are
  625. | zero.
  626. |
  627. | yeardayscalendar(self, year, width=3)
  628. | Return the data for the specified year ready for formatting (similar to
  629. | yeardatescalendar()). Entries in the week lists are day numbers.
  630. | Day numbers outside this month are zero.
  631. |
  632. | ----------------------------------------------------------------------
  633. | Data descriptors inherited from Calendar:
  634. |
  635. | __dict__
  636. | dictionary for instance variables (if defined)
  637. |
  638. | __weakref__
  639. | list of weak references to the object (if defined)
  640. |
  641. | firstweekday
  642. class TextCalendar(Calendar)
  643. | TextCalendar(firstweekday=0)
  644. |
  645. | Subclass of Calendar that outputs a calendar as a simple plain text
  646. | similar to the UNIX program cal.
  647. |
  648. | Method resolution order:
  649. | TextCalendar
  650. | Calendar
  651. | builtins.object
  652. |
  653. | Methods defined here:
  654. |
  655. | formatday(self, day, weekday, width)
  656. | Returns a formatted day.
  657. |
  658. | formatmonth(self, theyear, themonth, w=0, l=0)
  659. | Return a month's calendar string (multi-line).
  660. |
  661. | formatmonthname(self, theyear, themonth, width, withyear=True)
  662. | Return a formatted month name.
  663. |
  664. | formatweek(self, theweek, width)
  665. | Returns a single week in a string (no newline).
  666. |
  667. | formatweekday(self, day, width)
  668. | Returns a formatted week day name.
  669. |
  670. | formatweekheader(self, width)
  671. | Return a header for a week.
  672. |
  673. | formatyear(self, theyear, w=2, l=1, c=6, m=3)
  674. | Returns a year's calendar as a multi-line string.
  675. |
  676. | prmonth(self, theyear, themonth, w=0, l=0)
  677. | Print a month's calendar.
  678. |
  679. | prweek(self, theweek, width)
  680. | Print a single week (no newline).
  681. |
  682. | pryear(self, theyear, w=0, l=0, c=6, m=3)
  683. | Print a year's calendar.
  684. |
  685. | ----------------------------------------------------------------------
  686. | Methods inherited from Calendar:
  687. |
  688. | __init__(self, firstweekday=0)
  689. | Initialize self. See help(type(self)) for accurate signature.
  690. |
  691. | getfirstweekday(self)
  692. |
  693. | itermonthdates(self, year, month)
  694. | Return an iterator for one month. The iterator will yield datetime.date
  695. | values and will always iterate through complete weeks, so it will yield
  696. | dates outside the specified month.
  697. |
  698. | itermonthdays(self, year, month)
  699. | Like itermonthdates(), but will yield day numbers. For days outside
  700. | the specified month the day number is 0.
  701. |
  702. | itermonthdays2(self, year, month)
  703. | Like itermonthdates(), but will yield (day number, weekday number)
  704. | tuples. For days outside the specified month the day number is 0.
  705. |
  706. | itermonthdays3(self, year, month)
  707. | Like itermonthdates(), but will yield (year, month, day) tuples. Can be
  708. | used for dates outside of datetime.date range.
  709. |
  710. | itermonthdays4(self, year, month)
  711. | Like itermonthdates(), but will yield (year, month, day, day_of_week) tuples.
  712. | Can be used for dates outside of datetime.date range.
  713. |
  714. | iterweekdays(self)
  715. | Return an iterator for one week of weekday numbers starting with the
  716. | configured first one.
  717. |
  718. | monthdatescalendar(self, year, month)
  719. | Return a matrix (list of lists) representing a month's calendar.
  720. | Each row represents a week; week entries are datetime.date values.
  721. |
  722. | monthdays2calendar(self, year, month)
  723. | Return a matrix representing a month's calendar.
  724. | Each row represents a week; week entries are
  725. | (day number, weekday number) tuples. Day numbers outside this month
  726. | are zero.
  727. |
  728. | monthdayscalendar(self, year, month)
  729. | Return a matrix representing a month's calendar.
  730. | Each row represents a week; days outside this month are zero.
  731. |
  732. | setfirstweekday(self, firstweekday)
  733. |
  734. | yeardatescalendar(self, year, width=3)
  735. | Return the data for the specified year ready for formatting. The return
  736. | value is a list of month rows. Each month row contains up to width months.
  737. | Each month contains between 4 and 6 weeks and each week contains 1-7
  738. | days. Days are datetime.date objects.
  739. |
  740. | yeardays2calendar(self, year, width=3)
  741. | Return the data for the specified year ready for formatting (similar to
  742. | yeardatescalendar()). Entries in the week lists are
  743. | (day number, weekday number) tuples. Day numbers outside this month are
  744. | zero.
  745. |
  746. | yeardayscalendar(self, year, width=3)
  747. | Return the data for the specified year ready for formatting (similar to
  748. | yeardatescalendar()). Entries in the week lists are day numbers.
  749. | Day numbers outside this month are zero.
  750. |
  751. | ----------------------------------------------------------------------
  752. | Data descriptors inherited from Calendar:
  753. |
  754. | __dict__
  755. | dictionary for instance variables (if defined)
  756. |
  757. | __weakref__
  758. | list of weak references to the object (if defined)
  759. |
  760. | firstweekday
  761. FUNCTIONS
  762. calendar = formatyear(theyear, w=2, l=1, c=6, m=3) method of TextCalendar instance
  763. Returns a year's calendar as a multi-line string.
  764. firstweekday = getfirstweekday() method of TextCalendar instance
  765. isleap(year)
  766. Return True for leap years, False for non-leap years.
  767. leapdays(y1, y2)
  768. Return number of leap years in range [y1, y2).
  769. Assume y1 <= y2.
  770. month = formatmonth(theyear, themonth, w=0, l=0) method of TextCalendar instance
  771. Return a month's calendar string (multi-line).
  772. monthcalendar = monthdayscalendar(year, month) method of TextCalendar instance
  773. Return a matrix representing a month's calendar.
  774. Each row represents a week; days outside this month are zero.
  775. monthrange(year, month)
  776. Return weekday (0-6 ~ Mon-Sun) and number of days (28-31) for
  777. year, month.
  778. prcal = pryear(theyear, w=0, l=0, c=6, m=3) method of TextCalendar instance
  779. Print a year's calendar.
  780. prmonth(theyear, themonth, w=0, l=0) method of TextCalendar instance
  781. Print a month's calendar.
  782. setfirstweekday(firstweekday)
  783. timegm(tuple)
  784. Unrelated but handy function to calculate Unix timestamp from GMT.
  785. weekday(year, month, day)
  786. Return weekday (0-6 ~ Mon-Sun) for year, month (1-12), day (1-31).
  787. weekheader = formatweekheader(width) method of TextCalendar instance
  788. Return a header for a week.
  789. DATA
  790. __all__ = ['IllegalMonthError', 'IllegalWeekdayError', 'setfirstweekda...
  791. day_abbr = <calendar._localized_day object>
  792. day_name = <calendar._localized_day object>
  793. month_abbr = <calendar._localized_month object>
  794. month_name = <calendar._localized_month object>
  795. FILE
  796. d:\python38-32\lib\calendar.py
  797. >>>

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/IT小白/article/detail/417015
推荐阅读
相关标签
  

闽ICP备14008679号