• 获取python的版本&获取两个日期的天数差值


    import sys
    
    from datetime import datetime
    
    # Syntax sugar.
    _ver = sys.version_info  # 获取python版本
    
    #: Python 2.x?
    is_py2 = (_ver[0] == 2)     # is_py2 类型为布尔型,返回 False 或 True
    
    #: Python 3.x?
    is_py3 = (_ver[0] == 3)
    
    retire_day = datetime(2020, 1, 1)
    today = datetime.now()
    left_days = (retire_day - today).days   # 获取两个日期的天数差值
    
    if left_days > 0:
        retire_msg = "Python 2 will retire in {} days, why not move to Python 3?".format(left_days)
    else:
        retire_msg = "Python 2 has been retired, you should move to Python 3."
    
    print(_ver, "
    ", is_py2, is_py3)
    print(retire_msg)
  • 相关阅读:
    Canvas 绘画
    h5内容初探
    border&background1
    css3选择器补充
    bootstrap
    css3文本和颜色
    css3边框与背景
    css3选择器
    jQuery之dom操作(取赋值方法)
    push.default
  • 原文地址:https://www.cnblogs.com/testlearn/p/11466693.html
Copyright © 2020-2023  润新知