Ejemplo n.º 1
0
def calendar_():
    cal = calendar.month(2017, 6)  # by default w=2 l=1
    print cal  # 2017年6月份日历

    print '--------------------'
    # calendar内置函数
    #calendar of year 2017: c=distance(month); l=line(week); w=distance(day)
    print calendar.calendar(2017, w=2, l=1, c=6)  #lenth(line)= 21* W+18+2* C

    print calendar.firstweekday()  # start weekday, 0 by default, i.e. Monday
    # calendar.setfirstweekday(weekday)  # 0(Monday) to 6(Sunday)

    print calendar.isleap(2017)  # return True or False
    print calendar.leapdays(
        2000, 2016)  # number of leap years between year 1 and year 2

    print calendar.month(2017, 6)
    print calendar.monthcalendar(2017, 6)

    print calendar.monthrange(
        2017, 6)  # return (a, b)  a=starting weekday b=days in month

    calendar.prcal(
        2017, w=2, l=1,
        c=4)  # equals to print calendar.calendar(2017, w=2, l=1, c=4)
    calendar.prmonth(2017, 6)  # equals to print calendar.month(2017, 6)

    print calendar.timegm(
        time.localtime())  #和time.gmtime相反:接受一个时间元组形式,返回该时刻的时间辍

    print calendar.weekday(
        2017, 6, 30)  # calendar.weekday(year,month,day) return date code
Ejemplo n.º 2
0
def program():
    # Inputs for month and year
    month = input('Please enter month: ')
    year = input('Please enter year: ')

    try:
        # Return month current month if no inputs are entered
        if (month == '') and (year == ''):
            print('The current month is: ', datetime.now().month)

        # Returns month and current year if only month is entered
        elif (month != '') and (year == ''):
            calendar.prmonth(datetime.now().year, int(month))

        # Returns the whole calendar of that year if month is not entered
        elif (month == '') and (year != ''):
            calendar.prcal(int(year))

        # Returns the month and year if both are entered
        else:
            calendar.prmonth(int(year), int(month))
    except ValueError:
        print('Inputs are not in integer. Please try again.')

        # Restart program if there's an error
        program()
    finally:
        restart = input('Enter a new date? y or n: ')
        while (restart != 'y') and (restart != 'n'):
            restart = input('Please input y or n: ')
        else:
            if restart == 'y':
                program()
            elif restart == 'n':
                print('End Program')
Ejemplo n.º 3
0
    def dump(self, year, month) :
        weekName = ['MON','TUE','WED','THU','FRI','SAT','SUN']
        matrix = calendar.monthcalendar(year,month)

        """
        print year, month
        for week in matrix :
            for day in week :
                print '%02s'%(day),
            print
        """
        print

        print '%s (%s) %d\n'%(calendar.month_name[month],month,year)

        for day in weekName :
            print day,
        print
        
        for week in matrix :
            for day in week :
                if day == 0 :
                    print '%03s'%(' '),
                else :
                    print '%03s'%(day),
            print
        print

        print calendar.isleap(year)
        calendar.prmonth(year,month)
Ejemplo n.º 4
0
    def dump(self, year, month):
        weekName = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']
        matrix = calendar.monthcalendar(year, month)
        """
        print year, month
        for week in matrix :
            for day in week :
                print '%02s'%(day),
            print
        """
        print

        print '%s (%s) %d\n' % (calendar.month_name[month], month, year)

        for day in weekName:
            print day,
        print

        for week in matrix:
            for day in week:
                if day == 0:
                    print '%03s' % (' '),
                else:
                    print '%03s' % (day),
            print
        print

        print calendar.isleap(year)
        calendar.prmonth(year, month)
def calendar_():
  cal = calendar.month(2017, 6)  # by default w=2 l=1
  print cal  # 2017年6月份日历

  print '--------------------'
  # calendar内置函数
  #calendar of year 2017: c=distance(month); l=line(week); w=distance(day)
  print calendar.calendar(2017, w=2, l=1, c=6)  #lenth(line)= 21* W+18+2* C

  print calendar.firstweekday() # start weekday, 0 by default, i.e. Monday
  # calendar.setfirstweekday(weekday)  # 0(Monday) to 6(Sunday)

  print calendar.isleap(2017) # return True or False
  print calendar.leapdays(2000, 2016) # number of leap years between year 1 and year 2

  print calendar.month(2017, 6)
  print calendar.monthcalendar(2017, 6)

  print calendar.monthrange(2017, 6)  # return (a, b)  a=starting weekday b=days in month

  calendar.prcal(2017, w=2, l=1, c=4)  # equals to print calendar.calendar(2017, w=2, l=1, c=4)
  calendar.prmonth(2017, 6) # equals to print calendar.month(2017, 6)

  print calendar.timegm(time.localtime()) #和time.gmtime相反:接受一个时间元组形式,返回该时刻的时间辍

  print calendar.weekday(2017, 6, 30) # calendar.weekday(year,month,day) return date code
Ejemplo n.º 6
0
def monthCal(month=datetime_object.month, year=datetime_object.year):
    try:
        calendar.prmonth(year, month)
    except:
        print(
            'monthCal expects two arguments, 1. month (ex. 4) 2. year (ex. 2020)'
        )
Ejemplo n.º 7
0
def main():
    cal.setfirstweekday(cal.SUNDAY)
    datasets = [cal.day_name, cal.day_abbr, cal.month_name, cal.month_abbr]
    for calendar_data in datasets:
        print(list(calendar_data))

    print(cal.month(2016, 1))  # Calendar for January 2016
    cal.prmonth(2017, 3, w=5)  # Calendar for March 2017
Ejemplo n.º 8
0
def myCal(*args):
  print(args)
  if len(args) == 3:
    calendar.prmonth(int(args[2]), int(args[1]), w=0, l=0)
  elif len(args) == 2:
    calendar.prcal(int(args[1]))
  else:
    print(datetime.date(datetime.now()))
Ejemplo n.º 9
0
def get_calendar():
    if number_of_args == 1:
        print(calendar.prmonth(default_year, default_month))
    elif number_of_args == 2:
        print(calendar.prmonth(default_year, int(sys.argv[1])))
    elif number_of_args == 3:
        print(calendar.prmonth(int(sys.argv[1]), int(sys.argv[2])))
    else:
        print("Expected input calendar format: [# of month] [# of year]")
Ejemplo n.º 10
0
def print_calender(sys):
  if len(sys.argv) == 1:
    print(calendar.prmonth(current_year, current_month))
  elif len(sys.argv) == 2:
    print(calendar.prmonth(current_year, input_month))
  elif len(sys.argv) == 3:
    print(calendar.prmonth(input_year, input_month))
  else:
    print("Run this program in the foramt: 14_cal.py [month] [year]")
Ejemplo n.º 11
0
def custom_calendar(*argv):
    if len(argv) == 1:
        return calendar.prmonth(datetime.today().year, datetime.today().month)
    elif len(argv) == 2:
        return calendar.prmonth(datetime.today().year, int(argv[1]))
    elif len(argv) == 3:
        return calendar.prmonth(int(argv[1]), int(argv[2]))
    else:
        return "This program accepts 0-2 arguments. Too many arguments inputted. No inputs returns current month/year. One input specifies the month, two specifies month and year."
Ejemplo n.º 12
0
def print_calendar(userInput):

    if (len(userInput) == 2):
        return calendar.prmonth(int(year), int(userInput[1]))
    elif len(userInput) > 2:

        return calendar.prmonth(int(userInput[2]), int(userInput[1]))
    else:
        return calendar.prmonth(year, month)
Ejemplo n.º 13
0
def calendarview():
    bulan = raw_input("\nMasukkan bulan [MM]: \n")
    tahunini = int(datetime.datetime.now().year)
    calendar.prmonth(tahunini, int(bulan))
    print "9. Back"
    print "0. Quit"
    choice = raw_input(" >>  ")
    exec_menu(choice)
    return
Ejemplo n.º 14
0
def calendarview():
    bulan = raw_input("\nMasukkan bulan [MM]: \n")
    tahunini = int(datetime.datetime.now().year)
    calendar.prmonth(tahunini, int(bulan))
    print "9. Back"
    print "0. Quit"
    choice = raw_input(" >>  ")
    exec_menu(choice)
    return
Ejemplo n.º 15
0
def birthmonth():
# Takes user input for birth date information and prints the calendar of that month
  birthYear = raw_input("Enter the year of your birth:  ")
  birthMonth = raw_input("Enter the month of your birth as an integer:  ")
  try:
    calendar.prmonth(int(birthYear),int(birthMonth))
  except ValueError: 
    showInformation("Enter appropriate integers only.  Try again")
    birthmonth()
Ejemplo n.º 16
0
def datePicker():
    print('Enter Month and Year')
    x = input().split(' ')
    if x[0] == '':
        print(calendar.prmonth(int(datetime.today().strftime(
            '%Y')), int(datetime.today().strftime('%m'))))
    elif x[0] != '':
        print(calendar.prmonth(int(datetime.today().strftime(
            '%Y')), int(x[0])))
    else:
        print(calendar.prmonth(int(x[1]), int(x[0])))
Ejemplo n.º 17
0
def cal(*args):
    if args[0] == "" and args[1] == "":
        print(calendar.prmonth(datetime.utcnow().year,
                               datetime.utcnow().month))
    elif args[0] == "" or args[1] == "":
        print(calendar.prmonth(datetime.utcnow().year, int(args[0]
                                                           or args[1])))
    elif int(args[0]) >= 1 and int(args[0]) <= 12:
        print(calendar.prmonth(int(args[1]), int(args[0])))
    else:
        print("please add a correct month & year")
Ejemplo n.º 18
0
def any_month():
    """
    Prompt for year and month and print calendar.

    Two-digit years are converted according to the POSIX or X/Open standard: values 69-99 are mapped to 1969-1999, and values 0–68 are mapped to 2000–2068.
    """
    y= int( input( " ENTER: Year.............? " ) )
    if 69 <= y <= 99: y = y + 1900
    elif 0 <= y <= 68: y = y + 2000
    m= int( input( " ENTER: Month number.....? " ) )
    calendar.prmonth( y, m )
Ejemplo n.º 19
0
def main():
    cal.setfirstweekday(cal.SUNDAY)
    lists = (list(cal.day_name), list(cal.day_abbr), list(cal.month_name),
             list(cal.month_abbr))
    for aList in lists:
        print(aList)

    result = cal.month(2016, 1)  # Calendar for January 2016
    print(result)

    cal.prmonth(2017, 3, w=5)  # Calendar for March 2017
Ejemplo n.º 20
0
def dates():
  calendar.setfirstweekday(calendar.SUNDAY)
  independenceDay = calendar.weekday(1776, 7,5)
  weekDays = ['Sunday','Monday','Tuesday', 'Wednesday','Thursday','Friday','Saturday']
  printNow("Independence Day occured on a " + weekDays[independenceDay])
  calendar.prmonth(1985,8)
  today = date.today()
  my_birthday = date(today.year, 8, 19)
  if my_birthday < today:
    my_birthday = my_birthday.replace(year=today.year + 1)
  time_to_birthday = abs(my_birthday - today)
  printNow("Days till birthday: " + str(time_to_birthday.days))
  
Ejemplo n.º 21
0
def getMonth(month=today.month, year=today.year):
    try:
        int(month)
        int(year)
    except:
        print('Arguments must be castable as integers')
        return
    finally:
        if not (0 <= int(month) <= 12):
            print('Invalid month')
            return
        if int(year) < 0:
            print('invalid year')
            return
        calendar.prmonth(int(year), int(month))
Ejemplo n.º 22
0
def calc():
    currentMonth = datetime.now().month
    currentYear = datetime.now().year

    month = input("Enter a month: ")
    year = input("Enter a year: ")

    if (month != '' and year == ''):
        print(print(calendar.prmonth(currentYear, int(month))))
    elif (month != '' and year != ''):
        print(print(calendar.prmonth(int(year), int(month))))
    else:
        print(calendar.prmonth(currentYear, currentMonth))
        print('Please enter a month (ex: xx) and year (ex: xxxx)')
    sys.exit()
Ejemplo n.º 23
0
def problem2():
  from calendar import setfirstweekday, prmonth, weekday, day_name, month_name
  from datetime import date

  setfirstweekday(6)       # Set the week to start on Sunday.
  prmonth(1988, 2, 5, 1)   # Prints the month in a given year (with optional spacing).

  today = date.today()
  birthday = date(2019, 2, 13)        # Enter the date of your upcoming birthday to calculate how many days left.
  print str((birthday - today).days) + " days left until your birthday."

  independenceDay = date(1776, 7, 4)  # Independence Day.
  independenceDayD = day_name[independenceDay.weekday()]
  independenceDayM = month_name[independenceDay.month]
  independenceDayY = independenceDay.year
  print "Independence was declared on " + independenceDayD + ", " + independenceDayM, str(independenceDay.day) + ", " + str(independenceDayY)
Ejemplo n.º 24
0
def main():
    '''
    print calendar of 3 months including current month
    '''
    td = date.today()
    #this_month = td.month
    #print('this_month:', this_month)
    #calendar.prcal(td.year)

    #calendar.monthrange(td.year, td.month)

    TOTAL_MONTH = 3
    between_days = timedelta(days=30)
    for _ in range(TOTAL_MONTH):
        calendar.prmonth(td.year, td.month)
        td += between_days
Ejemplo n.º 25
0
def mainCalendar():
    #month = requestInteger("What month were you born?")
    month = 2
    #day = requestInteger("What day were you born?")
    day = 9
    #year = requestInteger("What year were you born?")
    year = 1984

    # Character formatting
    lengthSpacing = 0
    widthSpacing = 0

    print 'Here is your birthday month\n'
    print calendar.prmonth(year, month)
    print '\n'
    print date.today()
    print date.days
    print(date.today() - date(year, month, day)).days
Ejemplo n.º 26
0
def calendar_function(*args):
    if len(args) == 1:
        global year
        global month
        year = int(datetime.now().date().year)
        month = int(datetime.now().date().month)
        return calendar.prmonth(year, month)
    elif len(args) == 2:
        year = int(datetime.now().date().year)
        month = int(args[1])
        return calendar.prmonth(year, month)
    elif len(args) == 3:
        year = int(args[2])
        month = int(args[1])
        return calendar.prmonth(year, month)
    else:
        print(
            'This program accepts optional arguments for [month] and [year] in that order, do not pass more than 2 arguments.'
        )
        return
Ejemplo n.º 27
0
def printBirthMonth():
    #Get users birth month
    month = requestString("What Month were you born in:").lower()
    #Dictionary to convert month into an integer
    dic = {
        "january": 1,
        "february": 2,
        "march": 3,
        "april": 4,
        "may": 5,
        "june": 6,
        "july": 7,
        "august": 8,
        "september": 9,
        "october": 10,
        "november": 11,
        "december": 12
    }
    #Get users birth year
    year = requestInteger("What Year were you born in:")
    #Print the month of the corresponding month year
    calendar.prmonth(year, dic[month])
Ejemplo n.º 28
0
def cal(*args):
    current_month = datetime.now().month
    current_year = datetime.now().year
    if len(sys.argv) == 1:
        calendar.prmonth(current_year, current_month, w=1, l=1)
    elif len(sys.argv) == 2:
        calendar.prmonth(int(sys.argv[1]), current_month, w=1, l=1)
    elif len(sys.argv) == 3:
        calendar.prmonth(int(sys.argv[1]), int(sys.argv[2]), w=1, l=1)
    else:
        print('Format expects month and year broooo!')
    exit()
Ejemplo n.º 29
0
def my_calendar(*args):
    d = datetime.now()
    y = d.year
    m = d.month

    if len(args) == 0:
        calendar.prmonth(y, m)
    if len(args) == 1:
        calendar.prmonth(y, args[0])
    elif len(args) == 2:
        calendar.prmonth(args[1], args[0])
    else:
        print('Must only enter numbers and use format "mm, yyyy"')
Ejemplo n.º 30
0
def show_calendar(inputs):
    if inputs == 1:
        print("Calendar for the current month:")
        calendar.prmonth(datetime.today().year, datetime.today().month)
    elif inputs == 2:
        print(f"Calendar for month {int(sys.argv[1])} in year {datetime.today().year}:")
        calendar.prmonth(datetime.today().year, int(sys.argv[1]))
    elif inputs == 3:
        print(f"Calendar for month {int(sys.argv[1])} in year {int(sys.argv[2])}:")
        calendar.prmonth(int(sys.argv[2]), int(sys.argv[1]))
    else:
        print("""Error: Run the .py script without any input for the current month's calendar 
        OR run the .py script followed by a valid month or a valid month followed by the year 
        you wish to retrieve a calendar for.""")
Ejemplo n.º 31
0
def dates(string):
    x = string.split(' ')
    print(x)
    if x[0] == '14_cal.py':
        print(len(x))
        if len(x) == 2:
            month = x[1]
            if len(month) == 2:
                month_split = [int(d) for d in str(month)]
                print(month_split)
                if month_split[0] == 0:
                    if len(month_split) == 2:
                        month = [str(d) for d in month_split]
                        month = int(month[0] + month[1])
                        year = date.now().year
                        print(calendar.prmonth(year, month))
                    if len(month_split) == 1:
                        month = month_split[0]
                        year = date.now().year
                        print(calendar.prmonth(year, month))
                else:
                    month = [str(d) for d in month_split]
                    month = int(month[0] + month[1])
                    year = date.now().year
                    print(calendar.prmonth(year, month))
        if len(x) == 3:
            month = x[1]
            year = int(x[2])
            if len(month) == 2:
                month_split = [int(d) for d in str(month)]
                print(month_split)
                if month_split[0] == 0:
                    if len(month_split) == 2:
                        month = [str(d) for d in month_split]
                        month = int(month[0] + month[1])
                        print(calendar.prmonth(year, month))
                    if len(month_split) == 1:
                        month = month_split[0]
                        print(calendar.prmonth(year, month))
                else:
                    month = [str(d) for d in month_split]
                    month = int(month[0] + month[1])
                    print(calendar.prmonth(year, month))
    else:
        print('Please enter the proper format (HINT: ONLY 1 FILE'
              ' CAN BE SEARCHED AND ITS NAME IS 14_cal.py')
Ejemplo n.º 32
0
def calendar_input(args):
    print(sys.argv)
    print(args)
    today_date = datetime.now()
    year = today_date.year
    month = today_date.month

    input = len(args)
    print(input)

    if input == 1:
        calendar.prmonth(year, month)
    elif input == 2:
        calendar.prmonth(year, int(args[1]))
    elif input == 3:
        calendar.prmonth(int(args[2]), int(args[1]))
    else:
        print("Enter a [month] and a [year] like 5 2020 format")
Ejemplo n.º 33
0
def get_calendar(inpt=sys.argv):
    try:
        if len(inpt) == 1:
            month = datetime.now().month
            year = datetime.now().year
            calendar.prmonth(year, month)
        elif len(inpt) == 2:
            month = int(inpt[1])
            year = datetime.now().year
            calendar.prmonth(year, month)
        elif len(inpt) == 3:
            month = int(inpt[1])
            year = int(inpt[2])
            calendar.prmonth(year, month)
    except:
        print(
            "\ninput must be in the form of [month] [year] \n if you don't provide [year] I will use current year \n if you dont provide [month] and [year] I will use todays date"
        )
Ejemplo n.º 34
0
def show_calendar():
  today = datetime.today()
  if len(sys.argv) == 1:
    calendar.prmonth(today.year, today.month)
  elif len(sys.argv) == 2:
    month = sys.argv[1]
    try:
      calendar.prmonth(today.year, int(month))
    except:
      print("Months must be a number from 1 to 12.")
  elif len(sys.argv) == 3:
    month = sys.argv[1]
    year = sys.argv[2]
    try:
      calendar.prmonth(int(year), int(month))
    except:
      print("Enter a number between 1 and 12 for the month, then enter a year.")
  else:
    print("The Calendar takes 2 arguments, first enter a month, this is a number between 1 and 12. Next enter a number for the year.")
Ejemplo n.º 35
0
def create_calender(args):
    print(args)

    try:
        if (len(args) == 3):
            year = int(args[2])
            month = int(args[1])
            calendar.prmonth(theyear=year, themonth=month)
        if (len(args) == 2):
            year = int(date.year)
            month = int(args[1])
            calendar.prmonth(theyear=date.year, themonth=month)
        if (len(args) == 1):
            year = int(date.year)
            month = int(date.month)
            calendar.prmonth(theyear=date.year, themonth=date.month)
    except TypeError:
        print("Please try again with this format: '14_cal.py [month] [year]'")
    except ValueError:
        print("Please use numbers only")
Ejemplo n.º 36
0
def create_calander(date):
    #step 2 validate user response
    formatDate = date.split(' ')
    #if no input:
    if formatDate[0] == '':
        #print calander for the current month
        calendar.prmonth(datetime.now().year, datetime.now().month)

    #if input a month:
    if len(formatDate) == 1:
        if formatDate[0].isdigit():
            calendar.prmonth(datetime.now().year, int(formatDate[0]))
        else:
            print('month and date must be a number')
    # #if month and year:
    if len(formatDate) > 1:
        #print calendar for that month and year
        if formatDate[0].isdigit():
            calendar.prmonth(int(formatDate[1]), int(formatDate[0]))
        else:
            print('month and date must be a number')
Ejemplo n.º 37
0
Archivo: cal.py Proyecto: klheh/python
a = 10
b = 20
print a + b

import calendar
calendar.prmonth(2014, 11)
Ejemplo n.º 38
0
				cursor.execute("UPDATE notes SET due='"  +  dueupd
								 +  "' WHERE id='"  +  recid  +  "'")
			else:
				rtype = '0'
				cursor.execute("UPDATE notes SET type='"  +  rtype
								 +  "' WHERE id='"  +  recid  +  "'")
			conn.commit()
			print ('\nRecord has been updated.')
		elif command == 'tl':

# Show tasks

			cursor.execute ("SELECT due, id, note, tags FROM notes WHERE due <> '' AND tags NOT LIKE '%private%' AND type = '1' ORDER BY due ASC")
			print ("\n-----")
			now = datetime.datetime.now()
			calendar.prmonth(now.year, now.month)
			for row in cursor:
				print ("\n%s -- \033[1;32m%s\033[1;m %s \033[1;30m[%s]\033[1;m" % (row[0], row[1], row[2], row[3]))
				counter = counter + 1
			print ('\n-----')
			print ('\033[1;34mRecord count:\033[1;m %s' % counter)
			counter = 0
		elif command == 'at':

# Show records with attachments

			cursor.execute("SELECT id, note, tags, ext FROM notes WHERE ext <> 'None' AND type='1' ORDER BY id ASC")
			print ('\n-----')
			for row in cursor:
				print ('\n\033[1;32m%s\033[1;m %s \033[1;30m[%s]\033[1;m \033[1;43m%s\033[1;m' % (row[0], row[1], row[2], row[3]))
				counter = counter + 1
Ejemplo n.º 39
0
#_*_ coding: utf-8 _*_

import calendar
import sys

print sys.version
print
print sys.version_info

calendar.prmonth(2015, 12)
#  RKOCAR 
Ejemplo n.º 40
0
"""
calendar 模块

calendar 模块是 Unix  cal 命令的 Python 实现. 

它可以将给定年份/月份的日历输出到标准输出设备上.

"""
import calendar

# prmonth(year, month) 打印给定月份的日历
calendar.prmonth(2015, 9)

"""
    September 2015
Mo Tu We Th Fr Sa Su
    1  2  3  4  5  6
 7  8  9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
 [Finished in 0.3s]
 """

# prcal(year) 打印给定年份的日历
calendar.prcal(2015)
"""
                                   2015

      January                   February                   March
Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su      Mo Tu We Th Fr Sa Su
Ejemplo n.º 41
0
#!/usr/bin/env python
# file : cal.py
import calendar
calendar.prmonth(2009, 5)
Ejemplo n.º 42
0
#!/usr/bin/env python

# cal.py
# emulate the original Unix `cal` command

# TBD: highlight the current day (cross-platform Linux + Windows)

import sys

import calendar
import time   # simpler than datetime

calendar.setfirstweekday(calendar.SUNDAY)

if len(sys.argv) == 2:
  Y= sys.argv[1]
  calendar.prcal( int(Y) )
elif len(sys.argv) == 3:
  Y= sys.argv[1]
  m= sys.argv[2]
  calendar.prmonth( int(Y), int(m) )
else:
  Y= time.strftime('%Y')
  m= time.strftime('%m')
  calendar.prmonth( int(Y), int(m) )

#EOF
Ejemplo n.º 43
0
Archivo: test.py Proyecto: eunche/trunk
def putChar(a, b):
    if a > b:
        print('a')
    else:
        print('b')

for i in list(range(1, 10)):
    putChar(i, 10-i)

for i in list(range(2, 10)):
    for j in list(range(1, 10)):
        print(i, ' * ', j, ' = ', i * j)

print(list(map(lambda x: x ** 2, range(5))))

cs = []
s = 'Be happy!'
for c in s:
    cs.append(c)
print(cs)

import calendar
calendar.prmonth(1982, 5)

Ejemplo n.º 44
0
#!/usr/bin/python
#file: cal.py
import calendar
for x in range(1,12):
	calendar.prmonth(2016,x)
raw_input('\npress enter to exit!')

def bdayCalendar(birthday):
  """
  Show the calendar for the month of the year the user was born.
  """
  print "__Your Birthday Month:__"
  calendar.prmonth(birthday.year, birthday.month)
Ejemplo n.º 46
0
#!/usr/bin/env python3

'''use module calendar to show calendar of this year'''

import calendar
from datetime import date, timedelta

'''
print calendar of month, for 3 month including this month
'''
td = date.today()

#calendar.prcal(td.year)
calendar.prmonth(td.year, td.month)
#calendar.monthrange(td.year, td.month)
TOTAL_MONTH = 2
between_days = timedelta(days=30)
count = 0
while count < TOTAL_MONTH:
    count += 1
    td += between_days
    #print(td, td.month)
    calendar.prmonth(td.year, td.month)
Ejemplo n.º 47
0
# file: cal.py
import calendar
calendar.prmonth(2014, 9)
Ejemplo n.º 48
0
def month():
    calendar.prmonth(*localtime()[:2])
Ejemplo n.º 49
0
#!/usr/bin/python 
# 
# 
# A simple script to output a calendar month based off input from a Web form. 
# 
# 
import cgi,calendar 

print "Content-Type: text/html \n\n" 
print "<title>A month</title>" 
print "<body><pre>" 

form = cgi.FieldStorage() 
month = form.getvalue("month") 

try: 
	calendar.prmonth(2005, int(month),2,3) 
except Exception,e: 
	print "That is not a valid month" 
	
print "</body></pre>"
Ejemplo n.º 50
0
import calendar as cal
import time

print("Here's the calendar for the current month, %s:" % time.strftime('%B'))

t = time.localtime()
cal.prmonth(t.tm_year, t.tm_mon)
Ejemplo n.º 51
0
def ask_date():
    '''
    Will offer a printout of a monthly calendar covering the
    last 4 weeks, where this can be covering 1 or 2 months.
    Will then ask the user to supply a valid date.
    :return: the chosen date as struct_time
    '''
    # todone part 2: ask for date ...done
    previousday = time.localtime(time.time() - 86400)
    previousmonth = time.localtime(time.mktime(previousday) - 86400 * 28)
    print()
    if previousmonth[1] != previousday[1]:
        left = calendar.month(previousmonth[0], previousmonth[1], 3).split('\n')
        right = calendar.month(previousday[0], previousday[1], 3).split('\n')
        for counter in range(len(left)):
            print('%-27s   |  %-27s' % (left[counter], right[counter]))
    else:
        calendar.prmonth(previousday[0], previousday[1], 3)
    print('Gestern war der %s.' % (time.strftime('%d.%m.%Y (%A)', previousday)))
    print()
    print('Für welchen Tag soll der Kassenabschluss nachgeholt oder erneut erstellt werden?')

    print('\tJahr       [%s]: ' % previousday[0], end='')
    try:
        myyear=int(input(''))
        # only use the last two digits of the year entry:
        myyear=myyear % 100 + 2000
    except:
        # invalid entry will default to previous day's year
        myyear=previousday[0]
    if myyear > previousday[0]:
        # make sure that year is not in the future
        myyear=previousday[0]

    print('\tMonat (1-12) [%s]: ' % previousday[1], end='')
    try:
        mymonth=int(input(''))
        # only use the last two digits of the month entry:
        mymonth=mymonth % 100
    except:
        # invalid entry will default to previous day's month
        mymonth=previousday[1]
    if mymonth > 12:
        # make sure that month is not beyond December
        myyear=previousday[1]

    print('\tTag   (1-31) [%s]: ' % previousday[2], end='')
    try:
        myday=int(input(''))
    except:
        # invalid entry will default to previous day
        myday=previousday[2]
    if mymonth > 31:
        # make sure that month is not too highr
        myday=previousday[2]

    # check if day is in the future:
    if (time.strptime(str(myday) + '.' + str(mymonth) + '.' + str(myyear), '%d.%m.%Y')) > time.localtime():
        # in the future, so reset to previous day:
        myyear, mymonth, myday = previousday[0], previousday[1], previousday[2]
    # final date to be selected:
    print('--> Es wird der %s.%s.%s ausgewertet.' % (myday, mymonth, myyear))

    return time.strptime(str(myday) + '.' + str(mymonth) + '.' + str(myyear), '%d.%m.%Y')
Ejemplo n.º 52
0
print(time.localtime(time.time()))

print(time.asctime(time.localtime(time.time())))

print(time.ctime())

print(time.strftime('%c', time.localtime(time.time())))
for i in range(2):
    print(i)
    time.sleep(1)

# calendar
import calendar
calendar.prcal(2015) # print(calendar.calendar(2015))

calendar.prmonth(2015, 11)
print(calendar.weekday(2015, 11, 25)) # 2 weekday (mon=0, sun=6)

print(calendar.monthrange(2015, 11)) # (0, 30) weekday, day count

# random
import random
print(random.random())

print(random.randint(1,10)) # 1~10

print(random.choice(['a', 'b', 'c'])) 

d = [1,2,3]
random.shuffle(d)
print(d)
Ejemplo n.º 53
0
import datetime
import calendar

yr_s= int( input( " Start Year ............? " ) )
mo_s= int( input( " Start Month No. .......? " ) )
dy_s= int( input( " Start Day No. .........? " ) )
start= datetime.date( yr_s, mo_s, dy_s )
print( "Start date ................ ", start.strftime("%A, %B %d, %Y") )

yr_e= int( input( " End Year ............? " ) )
mo_e= int( input( " End Month No. .......? " ) )
dy_e= int( input( " End Day No. .........? " ) )
end= datetime.date( yr_e, mo_e, dy_e )
print( "End date ................ ", end.strftime("%A, %B %d, %Y") )

x = (end-start).days
print( " Days between dates .....{0:12d}".format(abs(x)) )
print( " Weeks between dates ....{0:12,.2f}".format(abs(x)/7) )
print( " Months between dates ...{0:12,.2f}".format(abs(x)/365.25*12) )
print( " Years between dates ....{0:12,.2f}".format(abs(x)/365.25) )
print()
print( "              (Weeks, months & years calculated to nearest full day)" )
calendar.setfirstweekday(calendar.SUNDAY)
print()
calendar.prmonth( start.year, start.month )
print("START  DATE")
print()
calendar.prmonth( end.year, end.month )
print("END  DATE")
print()
Ejemplo n.º 54
0
# file : cal02.py
import calendar
calendar.setfirstweekday(6)  # 일요일을 첫 요일로..
calendar.prmonth(2012, 6)
input()    # 키보드 입력받는 명령
Ejemplo n.º 55
0
import time
time.time()
time.localtime(time.time())
time.asctime(time.localtime(time.time()))
time.ctime()
time.strftime('%c', time.localtime(time.time()))

for i in range(10):
    print(i)
    time.sleep(1)

import calendar
print(calendar.calendar(2019))
calendar.prcal(2016)
calendar.prmonth(2015, 6)
calendar.weekday(2015, 6, 30) #0~6 -> 0 = 월, 1 = 화 .... 6= 일
calendar.monthrange(2015,12)

import random
random.random()
random.randint(1, 10)
random.randint(1, 55)

def random_pop(data):
    number = random.randint(0, len(data) - 1)
    return data.pop(number)

if __name__ == "__main__":
    data = [1, 2, 3, 4, 5]
    while data:
Ejemplo n.º 56
0
# -*- coding: utf-8 -*-

########################### 1장 #######################
# 1. 현재 버젼 정보 보기
import sys

print sys.version
print
print sys.version_info

# 2. 달력보기
import calendar

calendar.prmonth(2016, 2)  # 년, 월

########################### 2장 #######################
# 1. 예약어 종류보기
import keyword

print keyword.kwlist
print
print len(keyword.kwlist)

# - 정수 형태의 ASCll코드 값을 입력으로 받아 그에 해당하는 문자를 반환하는 함수
# - 인수 i의 범위: 0부터 255까지
print chr(97)
print chr(65)
print chr(48)

# - 임의의 객체 object에 대해 해당 객체를 표현하는 문자열을 반환하는 함수
print str(3)
Ejemplo n.º 57
0
from datetime import *
import calendar


print "Calendario!"
anno = input("Anno: ")

print datetime.today()

calendar.prcal(anno)

calendar.prmonth(anno,1)
Ejemplo n.º 58
0
import calendar
calendar.prmonth(1999, 12)

##     December 1999
## Mo Tu We Th Fr Sa Su
##        1  2  3  4  5
##  6  7  8  9 10 11 12
## 13 14 15 16 17 18 19
## 20 21 22 23 24 25 26
## 27 28 29 30 31
def birthMonth(year, month):
  calendar.prmonth(year, month)
Ejemplo n.º 60
0
#!/usr/bin/python
import calendar
'''
calendar.month(year,month,w=2,l=1)

Returns a multiline string with a calendar for month month of year year, one line per week plus two header
lines. w is the width in characters of each date; each line has length 7*w+6. l is the number of lines for each
week.

'''
cal=calendar.month(2008,2,6,2)
print "Here is the calendar: "
print cal;
cal1=calendar.prcal(2008,2,1,6)
'''
in the above code we don't required to use the print statement 
like print calendar.calendar(year,w,l,c)
'''

cal2=calendar.prmonth(2012,6,2,1)
#print cal2;

'''
Like print calendar.month(year,month,w,l).
'''