最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

基于Python實(shí)現(xiàn)倒計(jì)時(shí)工具

 更新時(shí)間:2022年08月09日 12:58:17   作者:aguang5241  
這篇文章主要為大家詳細(xì)介紹了基于Python實(shí)現(xiàn)倒計(jì)時(shí)工具,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

基于Python編寫的倒計(jì)時(shí)工具,供大家參考,具體內(nèi)容如下

特點(diǎn):

實(shí)時(shí)顯示當(dāng)前時(shí)間
自動(dòng)判斷用戶輸入日期,計(jì)算當(dāng)前日期與目標(biāo)日期相差大概多少年、月、日以及準(zhǔn)確的相差天數(shù)

運(yùn)行窗口

運(yùn)行界面-1

運(yùn)行界面-2

輸入日期-3

結(jié)果窗口-4

代碼

import time
import tkinter as tk
from tkinter import messagebox

def main():
? ? window1 = tk.Tk()
? ? window1.title('計(jì)時(shí)器【v0.0】')
? ? window1.geometry('300x200')

? ? l1 = tk.Label(window1, text = '當(dāng)前時(shí)間:', font = ('宋體', 15))
? ? l1.place(x = 5, y = 10)
? ?
? ? def time_now():
? ? ? ? global seconds_now
? ? ? ? seconds_now = time.time()
? ? ? ? lt = time.localtime(seconds_now)
? ? ? ? time1 = []
? ? ? ? time2 = '%04d年%02d月%02d日 ? ?\n ? ?%02d時(shí)%02d分%02d秒' % (lt[0], lt[1], lt[2], lt[3], lt[4], lt[5])

? ? ? ? if time2 != time1:
? ? ? ? ? ? time1 = time2
? ? ? ? ? ? l1_2 = tk.Label(window1, text = time1, font = ('宋體', 20))
? ? ? ? ? ? l1_2.configure(text = time2)
? ? ? ? ? ? l1_2.place(x = 30, y = 50)
? ? ? ? ? ? l1_2.after(200, time_now)
? ? ? ? ? ??
? ? time_now()
? ??
? ? def input_time():
? ? ? ? window2 = tk.Tk()
? ? ? ? window2.title('計(jì)時(shí)器【v0.0】')
? ? ? ? window2.geometry('300x120')

? ? ? ? l2_1 = tk.Label(window2, text = '年', font = ('宋體', 15))
? ? ? ? l2_1.place(x = 90, y = 20)
? ? ? ? l2_2 = tk.Label(window2, text = '月', font = ('宋體', 15))
? ? ? ? l2_2.place(x = 170, y = 20)
? ? ? ? l2_3 = tk.Label(window2, text = '日', font = ('宋體', 15))
? ? ? ? l2_3.place(x = 250, y = 20)
? ? ? ? l2_4 = tk.Label(window2, text = '有效日期【1970/1/2-3001/1/1】', font = ('宋體', 10))
? ? ? ? l2_4.place(x = 50, y = 50)

? ? ? ? year = tk.Entry(window2, text = None, font = ('宋體', 15), width = 5)
? ? ? ? month = tk.Entry(window2, text = None, font = ('宋體', 15), width = 5)
? ? ? ? day = tk.Entry(window2, text = None, font = ('宋體', 15), width = 5)
? ? ? ? year.place(x = 40, y = 20)
? ? ? ? month.place(x = 120, y = 20)
? ? ? ? day.place(x = 200, y = 20)

? ? ? ? def get_time():
? ? ? ? ? ? try:
? ? ? ? ? ? ? ? y = int(year.get())
? ? ? ? ? ? ? ? m = int(month.get())
? ? ? ? ? ? ? ? d = int(day.get())
? ? ? ? ? ? ? ? lt_ = time.strptime(f'{y} {m} wppm3vysvbp', '%Y %m %d')
? ? ? ? ? ? ? ? seconds_get = time.mktime(lt_)
? ? ? ? ? ? except BaseException:
? ? ? ? ? ? ? ? tk.messagebox.showerror(message='輸入有誤!')
? ? ? ? ? ? else:
? ? ? ? ? ? ? ? window2.withdraw() ? ?
? ? ? ? ? ??
? ? ? ? ? ? string1 = '查詢?nèi)掌诰嚯x現(xiàn)在還有:'
? ? ? ? ? ? string2 = '查詢?nèi)掌诰嚯x現(xiàn)在已過(guò)去:'

? ? ? ? ? ? seconds_lasting = seconds_get - seconds_now
? ? ? ? ? ??
? ? ? ? ? ? day_lasting = abs(seconds_lasting) // 86400
? ? ? ? ? ? month_lasting = 0
? ? ? ? ? ? year_lasting = 0
? ? ? ? ? ? days = day_lasting
? ? ? ? ? ?
? ? ? ? ? ? if day_lasting > 356:
? ? ? ? ? ? ? ? year_lasting = day_lasting // 365
? ? ? ? ? ? ? ? day_lasting -= year_lasting * 365
? ? ? ? ? ? ? ? if day_lasting > 30:
? ? ? ? ? ? ? ? ? ? month_lasting = day_lasting // 30
? ? ? ? ? ? ? ? ? ? day_lasting -= month_lasting * 30
? ? ? ? ? ? elif day_lasting > 30:
? ? ? ? ? ? ? ? year_lasting = 0
? ? ? ? ? ? ? ? month_lasting = day_lasting // 30
? ? ? ? ? ? ? ? day_lasting -= month_lasting * 30?
? ? ? ? ? ? else:
? ? ? ? ? ? ? ? year_lasting, month_lasting = 0, 0
? ? ? ? ? ??
? ? ? ? ? ? if seconds_lasting > 0:
? ? ? ? ? ? ? ? prompt = string1
? ? ? ? ? ? ? ? days += 1
? ? ? ? ? ? ? ? day_lasting += 1
? ? ? ? ? ? else:?
? ? ? ? ? ? ? ? prompt = string2 ?
? ? ? ? ? ? ? ? ??
? ? ? ? ? ? tk.messagebox.showinfo(message='%s%d天\n大概為%d年%d月%d天' % (prompt, days, year_lasting, month_lasting, day_lasting)) ??
? ? ? ? ? ? ? ??
? ? ? ? button2 = tk.Button(window2, text = '開始查詢', font = ('宋體', 15), command = get_time)
? ? ? ? button2.place(x = 110, y = 75)
? ? ? ?
? ? ? ? window2.mainloop()

? ? button1 = tk.Button(window1, text = '輸入查詢?nèi)掌?, font = ('宋體', 15), command = input_time)
? ? button1.place(x = 85, y = 125)

? ? window1.mainloop()

if __name__ == '__main__':
? ? main()

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • Python實(shí)現(xiàn)求解括號(hào)匹配問題的方法

    Python實(shí)現(xiàn)求解括號(hào)匹配問題的方法

    這篇文章主要介紹了Python實(shí)現(xiàn)求解括號(hào)匹配問題的方法,涉及Python基于棧的字符串遍歷、判斷、運(yùn)算解決括號(hào)匹配相關(guān)操作技巧,需要的朋友可以參考下
    2018-04-04
  • python3中的logging記錄日志實(shí)現(xiàn)過(guò)程及封裝成類的操作

    python3中的logging記錄日志實(shí)現(xiàn)過(guò)程及封裝成類的操作

    這篇文章主要介紹了python3中的logging記錄日志實(shí)現(xiàn)過(guò)程及封裝成類的操作,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-05-05
  • Redis之windows下主從復(fù)制案例講解

    Redis之windows下主從復(fù)制案例講解

    這篇文章主要介紹了Redis之windows下主從復(fù)制案例講解,本篇文章通過(guò)簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-08-08
  • Python的Tkinter點(diǎn)擊按鈕觸發(fā)事件的例子

    Python的Tkinter點(diǎn)擊按鈕觸發(fā)事件的例子

    今天小編就為大家分享一篇Python的Tkinter點(diǎn)擊按鈕觸發(fā)事件的例子,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2019-07-07
  • Python+threading模塊對(duì)單個(gè)接口進(jìn)行并發(fā)測(cè)試

    Python+threading模塊對(duì)單個(gè)接口進(jìn)行并發(fā)測(cè)試

    這篇文章主要為大家詳細(xì)介紹了Python+threading模塊對(duì)單個(gè)接口進(jìn)行并發(fā)測(cè)試,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2019-06-06
  • Python pandas如何向excel添加數(shù)據(jù)

    Python pandas如何向excel添加數(shù)據(jù)

    這篇文章主要介紹了Python pandas如何向excel添加數(shù)據(jù),文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2020-05-05
  • Python 布爾類型示例精講

    Python 布爾類型示例精講

    這篇文章主要為大家介紹了Python 布爾類型示例精講,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-10-10
  • 基于Python實(shí)現(xiàn)nc批量轉(zhuǎn)tif格式

    基于Python實(shí)現(xiàn)nc批量轉(zhuǎn)tif格式

    做項(xiàng)目有時(shí)會(huì)運(yùn)用到netCDF格式的氣象數(shù)據(jù),而ArcGIS中需要用柵格影像進(jìn)行處理,對(duì)于較多的文件,ArcGIS一個(gè)個(gè)手動(dòng)轉(zhuǎn)換過(guò)于繁瑣,因此我們采用Python進(jìn)行轉(zhuǎn)換,下面就是Python實(shí)現(xiàn)nc批量轉(zhuǎn)tif格式的示例代碼,希望對(duì)你有所幫助
    2022-08-08
  • DjangoRestFramework 使用 simpleJWT 登陸認(rèn)證完整記錄

    DjangoRestFramework 使用 simpleJWT 登陸認(rèn)證完整記錄

    Djangorestframework-simplejwt是Django REST Framework框架的一個(gè)jwt插件,使用 python http 工具進(jìn)行接口測(cè)試的方法文中給大家提到,重點(diǎn)給大家分享djangorestframework-simplejwt 使用記錄及登陸認(rèn)證的完成過(guò)程,感興趣的朋友跟隨小編一起看看吧
    2021-06-06
  • windows下pycharm搭建spark環(huán)境并成功運(yùn)行 附源碼

    windows下pycharm搭建spark環(huán)境并成功運(yùn)行 附源碼

    這篇文章主要介紹了windows下pycharm搭建spark環(huán)境并成功運(yùn)行 附源碼,本文分步驟給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-04-04

最新評(píng)論

伊吾县| 德江县| 漠河县| 剑河县| 米林县| 河东区| 花垣县| 东平县| 湖州市| 商洛市| 肥城市| 罗江县| 绥棱县| 钟祥市| 开阳县| 兴安盟| 扶沟县| 陈巴尔虎旗| 沛县| 北流市| 沾益县| 达拉特旗| 公安县| 阿坝| 库伦旗| 开化县| 普陀区| 禄丰县| 哈巴河县| 邳州市| 视频| 宁陕县| 清徐县| 大名县| 贵州省| 宕昌县| 湘阴县| 吉林省| 建阳市| 乐东| 靖西县|