Python keyboard input is basically similar to other programming languages, enter end input
Let's take a look at the keyboard input month day, English output example:
1 #!/usr/bin/env python2 #_*_ coding:utf-8 _*_3 #define the English month4months = ["January","February","March","April"," May","June","July","August","September",5 "October","November","December"]6 #define the end of days7endings = ["St","nd","Rd"] + 17 * ["th"] 8+ ["St","nd","Rd"] + 7 * ["th"] 9+ ["th"]Ten #Enter Month Day OneYear = input ("Year :") Amonth = input ("month (1-12):") -Day = input ("Day (1-31):") - #Convert a month and date to an integer type theMonth_number =Int (month) -Day_number =Int (day) - #get month and day and output -Month_name = Months[month_number-1] +Ordinal = day + endings[day_number-1] - Print(Month_name +' '+ ordinal +' '+ year)
Output Result:
1 year:20172 month (1-12): 23 Day (1-31):4 February 20th 2017
Python keyboard input