在python中创建倒计时时钟函数

在python中创建倒计时时钟函数,python,function,datetime,Python,Function,Datetime,我需要一个函数来打印变量sunset中捕获的设定时间与当前时间变量之间的剩余时间 from bs4 import BeautifulSoup import time import datetime res = requests.get('https://www.islamicfinder.org/world/romania/683506/bucharest-prayer-times/') soup = BeautifulSoup(res.text, 'html.parser') date =

我需要一个函数来打印变量
sunset
中捕获的设定时间与
当前时间
变量之间的剩余时间

from bs4 import BeautifulSoup
import time
import datetime
res = requests.get('https://www.islamicfinder.org/world/romania/683506/bucharest-prayer-times/')
soup = BeautifulSoup(res.text, 'html.parser')

date = soup.select('.font-weight-bold pt-date-right')
maghrib = soup.select('.prayertime')[-2]
title = maghrib.getText()
maghrib_time = title[:5]
maghrib_obj = datetime.datetime.strptime(maghrib_time, '%H:%M')
sunset = maghrib_obj.time()
clock_time = time.strftime('%H:%M:%S')
current_time_obj = datetime.datetime.strptime(clock_time, '%H:%M:%S')
current_time = current_time_obj.time()


def iftar_time(maghrib):
    title = str(maghrib.getText())
    print(f'iftar time for today is {title}'.capitalize())

def time_left():