成人国产在线小视频_日韩寡妇人妻调教在线播放_色成人www永久在线观看_2018国产精品久久_亚洲欧美高清在线30p_亚洲少妇综合一区_黄色在线播放国产_亚洲另类技巧小说校园_国产主播xx日韩_a级毛片在线免费

資訊專欄INFORMATION COLUMN

??國慶假期快到了,用python寫個倒計時程序,助你熬到假期!??

loonggg / 3836人閱讀

? ? ? ? 國慶假期快到了,想查查還有幾天幾小時到假期,這對程序員小菜一碟,輕輕松松用python寫個倒計時程序(天、時、分、秒),助你熬到假期!

一、先看效果:

?二、安裝python:

1、下載安裝python

下載安裝python3.9.6,進入python官方網站://www.python.org/

?點擊Python 3.9.6

直接安裝即可。

2、驗證安裝成功。

按win+R輸入cmd,打開控制臺,輸入python -V,輸出python版本號說明安裝成功。

三、代碼

##import libraryfrom tkinter import *import timefrom datetime import datetime,timedelta################GUI to display window ##########################root = Tk()root.geometry("450x300")root.resizable(0,0)root.config(bg ="blanched almond")root.title("國慶倒計時")Label(root, text = "國慶倒計時" , font = "arial 20 bold", bg ="papaya whip").pack()############GUI to display current time#######################Label(root, font ="arial 15 bold", text = " 當前時間:", bg = "papaya whip").place(x = 40 ,y = 70)#######################GUI to set the future time ##########Label(root, font ="arial 15 bold", text = " 到達時間:", bg = "papaya whip").place(x = 40 ,y = 110)#set yearyear_set = StringVar()Entry(root, textvariable =year_set , width = 4, font = "arial 12").place(x=175, y=115)Label(root, font ="arial 15", text = "-", bg = "papaya whip").place(x = 215 ,y = 110)year_set.set("0000")#set monthmonth_set= StringVar()Entry(root, textvariable =month_set, width =2, font = "arial 12").place(x=235, y=115)Label(root, font ="arial 15", text ="-", bg = "papaya whip").place(x = 260 ,y = 110)month_set.set("00")#set dayday_set= StringVar()Entry(root, textvariable =day_set, width =2, font = "arial 12").place(x=275, y=115)day_set.set("00")# set hourhour_set= StringVar()Entry(root, textvariable =hour_set, width =2, font = "arial 12").place(x=305, y=115)Label(root, font ="arial 15", text = ":", bg = "papaya whip").place(x = 330 ,y = 110)hour_set.set("00")# set minmin_set= StringVar()Entry(root, textvariable =min_set, width =2, font = "arial 12").place(x=345, y=115)Label(root, font ="arial 15", text = ":", bg = "papaya whip").place(x = 370 ,y = 110)min_set.set("00")# set secsec_set= StringVar()Entry(root, textvariable =sec_set, width =2, font = "arial 12").place(x=385, y=115)sec_set.set("00")#######################GUI to display timer countdown ##########Label(root, font ="arial 15 bold", text = " 倒計時:", bg ="papaya whip").place(x = 40 ,y = 150)#storing secondssec = StringVar()Entry(root, textvariable = sec, width = 2, font = "arial 12").place(x=325, y=155)Label(root, font ="arial 15", text = "秒", bg = "papaya whip").place(x = 350 ,y = 150)sec.set("00")#storing minutesmins= StringVar()Entry(root, textvariable = mins, width =2, font = "arial 12").place(x=275, y=155)Label(root, font ="arial 15", text = "分", bg = "papaya whip").place(x = 300 ,y = 150)mins.set("00")# storing hourshrs= StringVar()Entry(root, textvariable = hrs, width =2, font = "arial 12").place(x=225, y=155)Label(root, font ="arial 15", text = "時", bg = "papaya whip").place(x = 250 ,y = 150)hrs.set("00")# storing daysdays= StringVar()Entry(root, textvariable = days, width =2, font = "arial 12").place(x=175, y=155)Label(root, font ="arial 15", text = "天", bg = "papaya whip").place(x = 200 ,y = 150)days.set("00")#########fun to display current time#############def clock(): clock_time = time.strftime("%Y-%m-%d %H:%M:%S %p") curr_time.config(text = clock_time) curr_time.after(1000,clock)curr_time =Label(root, font ="arial 15 bold", text = "", fg = "gray25" ,bg ="papaya whip")curr_time.place(x = 175 , y = 70)clock()##########fun to start countdown########def countdown(): #now = datetime.now() #end = datetime((year_set).get(),(month_set).get(),(day_set).get(),(hour_set).get(),(min_set).get(),(sec_set).get(),00); global seconds_now now = time.time() lt_ = time.strptime(f"{(year_set).get()} {(month_set).get()} {(day_set).get()} {(hour_set).get()} {(min_set).get()} {(sec_set).get()}", "%Y %m %d %H %M %S") end = time.mktime(lt_) times=int (end-now)  #.total_seconds()); while times > -1:  minute,second = (times // 60 , times % 60)    hour = 0  if minute > 60:   hour , minute = (minute // 60 , minute % 60)    day=0  if hour>24:    day,hour=(hour//24,hour%24)      sec.set(second)  mins.set(minute)  hrs.set(hour)  days.set(day)  root.update()  time.sleep(1)  times -= 1Button(root, text="START", bd ="5", command = countdown, bg = "antique white", font = "arial 10 bold").place(x=150, y=210)  root.mainloop()

四、運行

打開工程文件,在地址欄里輸入cmd,按Enter回車,即打開控制臺。

?輸入python main.py,按回車就打開了程序GUI界面。

?到達時間填2021年10月1日,按start按鈕,就開始放假倒計時啦!

?相關資源:基于python的假期倒計時(天、時、分、秒).zip

文章版權歸作者所有,未經允許請勿轉載,若此文章存在違規(guī)行為,您可以聯系管理員刪除。

轉載請注明本文地址:http://systransis.cn/yun/121688.html

相關文章

  • ??國慶七天的總結

    今年國慶七天和以往就不一樣了,過去都是學生時代的國慶,大學時光以前在家有家人的陪伴,在大學階段也基本沒回過家。 這里說明一下不怎么回家的原因吧,因為我老家在農村里,國慶階段是收集油茶樹果實的好時光,就從網上拿了一張圖,大概就是如下樣子,碩果累累(說不定有些小伙伴還不知道這啥,因為我問了一些朋友都說不知道這回事,農村里的小伙伴可能會知道)。 往年的國慶 還記得初中那會還和家里人一起上山采摘過,不過...

    0xE7A38A 評論0 收藏0
  • 國慶看了長津湖 | 堅韌的毅力讓我拿到了薪資18.5K,人生就像馬拉松,堅持到最后,就是勝利者

    摘要:戰(zhàn)爭已勝,精神依在,當延續(xù)了這份堅韌與毅力之后,所有事情都將變得有無限可能,本期成功就業(yè)的小余,正是憑借著這股毅力,完成了夢想,取得了高薪。 伴隨著7天國慶長假落...

    smallStone 評論0 收藏0
  • 國慶假期學門新技術,拒絕只做crud boy, 就從操作系統(tǒng)開始(三)

    摘要:因為操作系統(tǒng)一直被看做是計算機軟件的基石。本系列是我學習操作系統(tǒng)的筆記,操作系統(tǒng)是以為例子。其他的操作系統(tǒng)也是差不多。將設備驅動一共分為個級別,每個級別的驅動初始化聲明宏定義及其在系統(tǒng)啟動過程中的啟動順序如下表所示。 老板說我技術需要有長進,不能只做一個crud boy。 于是我選來選去,...

    Hegel_Gu 評論0 收藏0
  • 我的秋招復盤——回顧2022秋招經歷

    摘要:接下來,我主要從三個階段回顧我的秋招,分別是前期中期尾聲。到了這里,我的秋招算是正式的塵埃落定了,簽完三方后,我的秋招結束了。四復盤總結這次的復盤主要是我自己整個秋招的歷程縮影,很多細節(jié)無法在一篇文章就說清楚。 ...

    longshengwang 評論0 收藏0
  • 程序人生】?階段總結?-芝草無根

    ?階段一:回顧過往 ? ? ? ? 好久沒有更新博客了?(鴿了太久),嘿嘿,感覺是時候回過頭來寫一篇了...... ? ? ? ? 主要是因為國慶假期快過去了,才發(fā)現自己好像什么事都沒有開始做。確實深有體會:人越長大,時間過得越快,當下的我就處在時間飛逝的浮光掠影之中...... ? ? ? ? 后端的基礎經過一年多的不斷學習,漸漸進入了尾聲...終于在國慶不久前進入了分布式、SpingCloud...

    darryrzhong 評論0 收藏0

發(fā)表評論

0條評論

最新活動
閱讀需要支付1元查看
<