import calendar year = input("Type in the year number:") calendar.prcal(year)±×¸®°í ¿©±â¿¡ ³»°¡ ¾òÀº Ãâ·ÂÀÇ ÀϺθ¦ º¸ÀδÙ:
Type in the year number:2001 2001 January February March Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su Mo Tu We Th Fr Sa Su 1 2 3 4 5 6 7 1 2 3 4 1 2 3 4 8 9 10 11 12 13 14 5 6 7 8 9 10 11 5 6 7 8 9 10 11 15 16 17 18 19 20 21 12 13 14 15 16 17 18 12 13 14 15 16 17 18 22 23 24 25 26 27 28 19 20 21 22 23 24 25 19 20 21 22 23 24 25 29 30 31 26 27 28 26 27 28 29 30 31(³»°¡ ¸î °³ÀÇ Ãâ·ÂÀ» »ý·«ÇßÁö¸¸, ¿©·¯ºÐÀº ÀÌÇظ¦ Çϸ®¶ó°í »ý°¢ÇÑ´Ù.) ÀÚ ±× ÇÁ·Î±×·¥Àº ¹«¾ùÀ» Çϴ°¡? ù ¹ø° ¶óÀÎ import calendar´Â »õ·Î¿î ¸í·É¾î import¸¦ »ç¿ëÇÏ°í ÀÖ´Ù. import¸í·É¾î´Â ÇϳªÀÇ ¸ðµâÀ» ÀÐ¾î µéÀδÙ. (ÀÌ °æ¿ì¿¡´Â calendar ¸ðµâ). ±× ¸í·É¾î°¡ Ç¥ÁØ ¸ðµâ¿¡¼ »ç¿ë°¡´É ÇÑÁö ¾Ë¾Æº¸·Á¸é (´Ù¿î·Îµå ¹Þ¾Ò´Ù¸é) ÆÄÀ̽㠶óÀ̺귯¸® ÂüÁ¶¼¸¦ »ìÆ캸µçÁö ¾Æ´Ï¸é http://www.python.org/doc/current/lib/lib.html·Î °¡º¸¶ó. ´Þ·Â ¸ðµâÀº 5.9¿¡¼ ¼³¸íÇÑ´Ù. ¿©·¯ºÐÀÌ ±× ÁÖ¼®ÀÇ ¸®½ºÆ®¸¦ Àß »ìÆ캸¸é ÇϳªÀÇ ÇÔ¼ö°¡ ÀϳâÄ¡ ´Þ·ÂÀ» Ãâ·ÂÇÏ´Â 'prcal' À» È£ÃâÇÏ°í ÀÖ´Ù. " calendar.prcal(year) "¶óÀÎÀº ÇÔ¼ö¸¦ »ç¿ëÇÑ´Ù. ¿ä¾àÇÏÀÚ¸é, ¸ðµâÀ» »ç¿ëÇÏ·Á¸é ±×°ÍÀ» ¼öÀÔ(import)Ç϶ó ±×¸®°í ±× ¸ðµâ¿¡¼ÀÇ ÇÔ¼ö¸¦ »ç¿ëÇÏ·Á¸é module_name.function ÀÇ Çü½ÄÀ¸·Î »ç¿ëÇ϶ó
from calendar import prcal year = input("Type in the year number:") prcal(year)ÀÌ ¹öÀüÀº ¸ðµâ¿¡¼ Ưº°ÇÑ ÇÔ¼ö Çϳª¸¸À» ¼öÀÔÇÑ´Ù.
from time import time, ctime prev_time = "" while(1): the_time = ctime(time()) if(prev_time != the_time): print "The time is:",ctime(time()) prev_time = the_time¿©±â¿¡ ¾à°£ÀÇ Ãâ·ÂÀ» º¸ÀδÙ:
The time is: Sun Aug 20 13:40:04 2000 The time is: Sun Aug 20 13:40:05 2000 The time is: Sun Aug 20 13:40:06 2000 The time is: Sun Aug 20 13:40:07 2000 Traceback (innermost last): File "clock.py", line 5, in ? the_time = ctime(time()) KeyboardInterruptÃâ·ÂÀº ¹°·Ð ¹«ÇÑÀÌ´Ù ±×·¡¼ ³ª´Â ±×°ÍÀ» Ãë¼Ò½ÃÄ×´Ù.(±×·¸Áö ¾ÊÀ¸¸é Ãâ·ÂÀº Àû¾îµµ ÄÜÆ®·Ñ+C¸¦ ´©¸¦ ¶§±îÁö´Â °è¼ÓµÈ´Ù.) ±× ÇÁ·Î±×·¥Àº ¹«ÇÑ ·çÇÁ¸¦ µ¹°í ÀÖ´Â ÁßÀÌ°í ±× ¶§¸¶´Ù ½Ã°£ÀÌ º¯Çß´ÂÁö ¾Æ´ÑÁö¸¦ Á¡°ËÇؼ ¸¸¾à º¯Çß´Ù¸é ±×°ÍÀ» Ãâ·ÂÇÑ´Ù. 'from time import time, ctime7' ¿¡¼ import¼¼ú¹® µÚ¿¡ ¿©·¯°³ÀÇ À̸§ÀÌ »ç¿ëµÈ´Ù´Â °ÍÀ» ÁÖ¸ñÇ϶ó.
ÆÄÀ̽㠶óÀ̺귯¸®´Â ¸¹Àº À¯¿ëÇÑ ÇÔ¼öµéÀ» ´ã°í ÀÖ´Ù. ÀÌ·¯ÇÑ ÇÔ¼öµé·Î ¿©·¯ºÐÀÇ ÇÁ·Î±×·¥Àº ´õ¿í ´õ ´É·ÂÀ» °®°ÔµÇ°í ±×µéÁßÀÇ ¸¹Àº °ÍµéÀº ÆÄÀ̽㿡¼ÀÇ ÇÁ·Î±×·¡¹ÖÀ» ½±°Ô ÇÑ´Ù.