简体   繁体   English

每 24 小时发送一次 WhatsApp 消息

[英]Send WhatsApp message every 24 hours

I want to send a WhatsApp message every 24 hours automatically using python, with the pywhatkit library.我想使用 python 和 pywhatkit 库每 24 小时自动发送一条 WhatsApp 消息。 Here is the code I got so far:这是我到目前为止得到的代码:

import pywhatkit

pywhatkit.sendwhatmsg("+91xxxxxxxxxx", "Hello, world", 16, 00)

Send every 24 hours adaptation:每 24 小时适配发送一次:

import pywhatkit
import time
   
while True:
    time.sleep(86400) #86400 seconds in a day
    pywhatkit.sendwhatmsg("+91xxxxxxxxxx","Hello, world", 16, 00)

I would have to keep my PC on 24/7 for this to work.我必须让我的电脑全天候 24/7 才能工作。 Is there any better way of doing it?有没有更好的方法呢?

See you can use pywhatkit, and can add a loop using python library like this you can get hours看到你可以使用 pywhatkit,并且可以使用 python 库添加一个循环,这样你可以获得几个小时

from datetime import datetime

# datetime object containing current date and time
now = datetime.now()
 
import time

time.strftime('%X') // '13:12:47'

time.strftime('%x') // '01/20/22'

time.strftime('%d') // '20' day

time.strftime('%m') // '01' month

time.strftime('%y') // '20' year

time.strftime('%H') // '01' hour

time.strftime('%M') // '01' minute

time.strftime('%m') // '01' second

but I recommend instead of pywhatkit use this, this is very fast and never misses,但我建议不要使用 pywhatkit 而不是使用它,它非常快而且不会错过,

https://stackoverflow.com/a/71168835/6236959 https://stackoverflow.com/a/71168835/6236959

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM