首页 > 编程语言 >python: calendar

python: calendar

时间:2023-07-08 09:22:57浏览次数:32  
标签:target python nowtime datetime 时间 print calendar

 

import calendar

    yy=int(input("请输入年份:"))
    calendar.setfirstweekday(firstweekday=0) #为了符合习惯,指定日历的第一天是星期一
    calendar.prcal(yy,w=0,l=0,c=0,m=4) #显示日历,c=0  为一周的第一天为星期一,与上面对应

  

结果:

    #倒计时
    nowtime=datetime.datetime.now()
    print("当前时间为:",nowtime)
    targetdate=input("输入时间以-分隔,例如:2023-7-8 23:10:10\n")
    target=datetime.datetime.strptime(targetdate,"%Y-%m-%d %H:%M:%S")
    print("目上标时间:",target)
    while True:
        nowtime=datetime.datetime.now()
        if target>nowtime:
            print("时间未到,当前时间为:",nowtime)
            time.sleep(1)

        else:
            print("时间已经到")
            break
    print("ok")

  

 

标签:target,python,nowtime,datetime,时间,print,calendar
From: https://www.cnblogs.com/geovindu/p/17536623.html

相关文章

  • [学习笔记]python爬虫初体验
    同学吹水,提到了爬虫,于是金工实习回来晚上看了看爬虫(话说为啥所有爬虫教程前面都是一大串python基础教程啊)importurllib.request#1、定义一个网址urlurl='http://www.baidu.com'#2、模拟浏览器向服务器发送请求response=urllib.request.urlopen(url)print(type(response......
  • [oeasy]python0071_字符串类型_str_string_下标运算符_中括号
    回忆上次内容上次分辨了静态类型语言动态类型语言 python属于对类型要求没有那么严格的动态类型语言 对初学者很友好不过很多时候也容易弄不清变量类型 直接修改代码增强程序的可读性把变量的类型明确标......
  • python命令
    目录进入项目文件终端:cmd进去目标文件:cd查找当前盘或者文件下面的目录:dirnull进入项目文件终端:cmd进去目标文件:cd查找当前盘或者文件下面的目录:dir//创建项目工程:django-adminstartprojectCarApp:pythonmanage.pystartappblog//配置用户信息pythonmanage.pycre......
  • python: PyQt5 beginner
     fromPyQt5.QtWidgetsimportQWidget,QApplication,QMainWindow,QLabel,QPushButtonfromPyQt5importQtCore,QtGuiimportsysimportosdefclick():print("HyButtonisclicked!")#Pressthegreenbuttonintheguttertorunthescri......
  • Python | glob模块使用
    glob模块简介glob模块可以查找符合特定规则的文件路径名,用来查找文件目录和文件,并将搜索的到的结果返回到一个列表中。常见的两个方法有glob.glob()和glob.iglob(),类似windows下的文件搜索。glob支持*?[]这三种通配符。glob模块的使用导入方法:importglob #导入整个glob模......
  • python基础day40
    GIL全局解释器锁python在设计之初就考虑到在主循环中,同时只有一个线程在执行。虽然Python解释器中可以“运行”多个线程,但在任意时刻只有一个线程在解释器中运行。对Python虚拟机的访问由全局解释器锁(GIL)来控制,正是这个锁能保证同一时刻只有一个线程在运行。1.python代码......
  • python字典(二)- 嵌套
    1.字典列表alien_0={'color':'green','points':5}alien_1={'color':'yellow','points':10}alien_2={'color':'red','points':15}aliens=[alien_0,alien_1,alie......
  • Python 引用问题 - ImportError: attempted relative import with no known parent pa
    问题描述近日在尝试引用其他文件的代码时,遇到了错误:ImportError:attemptedrelativeimportwithnoknownparentpackage.问题大致是这样的:我想在code2.py中引用code1.py的函数,如from..folder1.code1importxxx,运行code2.py时出现错误。root├──folder1│......
  • python函数进阶
    Python函数进阶一、函数多返回值1.1多个返回值如果一个函数要有多个返回值,该如何书写代码?"""演示函数的多返回值示例"""#演示使用多个变量,接受多个返回值deftest_return():return1,"hello",Truex,y,z=test_return()print(x)#1print(y)#hello......
  • python multiprocessing库使用记录
    pythonmultiprocessing库使用记录需求是想并行调用形式化分析工具proverif,同时发起对多个query的分析(378个)。实验室有40核心80线程的服务器(双cpu,至强gold5218R*2)。观察到单个命令在分析时内存占用不大,且只使用单核心执行,因此考虑同时调用多个命令同时执行分析,加快结果输出。......