Python 退出 while 循环并只打印一次
Python exit while loop and print only once
我想循环“时间”直到 12:30 但只打印一次。我该怎么做?
@client.event
async def on_ready():
reminder.start()
print("rdy")
@tasks.loop()
async def reminder():
i= 0
now = datetime.datetime.now()
start= now.replace(hour=22, minute=45, second=0, microsecond=0)
if now<start:
await client.get_channel(852950484842315786).send(f"works")
Output
看看时间就知道了。
@tasks.loop(seconds=60)
async def remider():
i= 0
o= 0
now = datetime.datetime.now()
start= now.replace(hour=12, minute=30, second=0, microsecond=0)
if now<start:
await client.get_channel(852950484842315786).send(f"works")
一件事是在文件末尾你必须通过
开始循环
reminder.start()
我想循环“时间”直到 12:30 但只打印一次。我该怎么做?
@client.event
async def on_ready():
reminder.start()
print("rdy")
@tasks.loop()
async def reminder():
i= 0
now = datetime.datetime.now()
start= now.replace(hour=22, minute=45, second=0, microsecond=0)
if now<start:
await client.get_channel(852950484842315786).send(f"works")
Output
看看时间就知道了。
@tasks.loop(seconds=60)
async def remider():
i= 0
o= 0
now = datetime.datetime.now()
start= now.replace(hour=12, minute=30, second=0, microsecond=0)
if now<start:
await client.get_channel(852950484842315786).send(f"works")
一件事是在文件末尾你必须通过
开始循环reminder.start()