zoukankan      html  css  js  c++  java
  • 索引脚本实例1

     根据给定的年月日以数字的形式打印日期
    1
    #!/usr/bin/env python 2 #encoding: utf-8 3 months = [ 4 'January', 5 'February', 6 'March', 7 'April', 8 'May', 9 'June', 10 'July', 11 'August', 12 'September', 13 'Otober', 14 'November', 15 'December' 16 ] 17 #以1-31的数字作为结尾的列表 18 endings = ['st','nd','rd'] + 17 * ['th'] 19 + ['st','nd','rd'] + 7 * ['th'] 20 + ['st'] 21 year = raw_input('year: ') 22 month = raw_input('Month(1-12): ') 23 day = raw_input('Day(1-31): ') 24 25 month_number = int(month) 26 day_number = int(day) 27 28 #记得要将月份和天数减1,以获得正确的索引 29 month_name = months[month_number - 1] 30 ordinal = day + endings[day_number - 1] 31 32 print month_name + ' ' + ordinal + ',' + year

    执行结果:
    [root@localhost script]# python 1.py
    year: 1942
    Month(1-12): 12
    Day(1-31): 1
    December 1st,1942


  • 相关阅读:
    服务管理器
    自动启动管理器
    进程管理器
    进程模块查看器
    无DLL远程注入
    远程DLL注入
    U盘免疫
    WSAAsyncSelect Demo
    select Demo
    校正系统时间
  • 原文地址:https://www.cnblogs.com/yangmingxianshen/p/7690050.html
Copyright © 2011-2022 走看看