【问题标题】:Pywhatkit instant message to group gets error "'sleep_time' not defined"Pywhatkit 即时消息组收到错误“\'sleep_time\' not defined\”
【发布时间】:2023-02-14 15:33:13
【问题描述】:

我从使用 Pywhatkit 立即向 Whatsapp 组发送消息的网站获得了以下代码:

import pywhatkit

# syntax: phone number with country code, message
pywhatkit.sendwhatmsg_to_group_instantly('XXXXXXXXXXXXXXXX', 'Test')

(当然我代码中的XXXXXXXXXXXXXXXX是正确的,只是不想泄露而已)

但是由于某种原因运行它会返回以下错误:

Traceback (most recent call last):
  File "C:\Users\Noam\PycharmProjects\Whatsapp\Whatsappdo.py", line 4, in <module>
    pywhatkit.sendwhatmsg_to_group_instantly('XXXXXXXXXXXXXXXX', 'Test')
  File "C:\Users\Noam\PycharmProjects\Whatsapp\venv\lib\site-packages\pywhatkit\whats.py", line 128, in sendwhatmsg_to_group_instantly
    time.sleep(sleep_time)
NameError: name 'sleep_time' is not defined

我认为我调用函数的方式没有问题,问题是什么?

【问题讨论】:

  • 您可能使用的是过时版本的软件包吗? the current github master doesn't have the line that throws the error。事实上,that line was changed in this commit,所以看起来你有旧的、有问题的包版本。作为解决方法,您可以在已安装的软件包中编辑该行。
  • (作为旁注,我发现在一个名为sendwhatmsg_to_group_instantly 的函数中,它做的第一件事是休眠 4 秒,这很有趣)
  • @GPhilo 太奇怪了,因为 Pycharm 告诉我我使用的是 5.3 版,我什至尝试删除它并重新安装它,但它仍然有相同的错误!我会在 VS Code 中尝试,如果这没有帮助,我会手动更改它,谢谢!
  • pip 上可用的最新版本可能仍然过时,他们还没有推送“修复”。
  • 好,谢谢!只是手动更改了它。

标签: python whatsapp nameerror


【解决方案1】:

你没有定义它应该是这样的时间: pywhatkit.sendwhatmsg("+919XXXXXXXXX", “极客对极客!”, 12, 40, 10, 正确, 2)

12,40 = 12:40PM(它使用 24 小时格式)这是您要发送消息的时间。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2023-01-09
    • 2021-06-11
    • 1970-01-01
    • 1970-01-01
    • 2015-02-20
    • 2020-11-17
    • 1970-01-01
    • 2021-03-05
    相关资源
    最近更新 更多