当我将pywhkit库放在里面时,烧瓶应用程序不会编译

发布于 2025-02-07 18:06:19 字数 1190 浏览 3 评论 0原文

我在烧瓶中有一个应用程序,并试图在该应用程序中插入一个代码,以自动将消息发送到WhatsSAP。

  • 代码:
import pywhatkit as pwk
import time


def whats():
    tim = time.localtime()

    hour = int(time.strftime("%H", tim))
    min = int(time.strftime("%M", tim))

    if min==59:
        min = 0
    else:
        min += 1
    # using Exception Handling to avoid unexpected errors
    try:
          # sending message in Whatsapp in India so using Indian dial code (+91)
          pwk.sendwhatmsg("+5587988758805", "Trabalhador sem EPI!", hour, min)
          print("Message Sent!") #Prints success message in console
    # error message
    except: 
        print("Error in sending the message")

两个代码都可以完美地工作,但是当我将两个代码放在一起时,代码不会编译。

我做了一些测试:

  1. 我尝试只是在烧瓶应用程序中将pywhkit导入为pwk;

  2. 我尝试在另一个python文件中使用代码并导入;

  3. 我试图将两个代码放在同一python文件中。

在所有情况下,代码都不编译,当我调试测试1的代码时,我会收到以下错误:

Exception has occurred: SystemExit 3
  File "C:\Users\diego\codes\Working\modify.py", line 96, in <module>
    app.run(debug=True)

为什么在将 pywhwhkit 库放入烧瓶应用程序中时,我不能编译代码?

I have an application in flask and I tried to insert within that application a code to automatically send messages to whatssap.

  • Code:
import pywhatkit as pwk
import time


def whats():
    tim = time.localtime()

    hour = int(time.strftime("%H", tim))
    min = int(time.strftime("%M", tim))

    if min==59:
        min = 0
    else:
        min += 1
    # using Exception Handling to avoid unexpected errors
    try:
          # sending message in Whatsapp in India so using Indian dial code (+91)
          pwk.sendwhatmsg("+5587988758805", "Trabalhador sem EPI!", hour, min)
          print("Message Sent!") #Prints success message in console
    # error message
    except: 
        print("Error in sending the message")

Both codes are working perfectly, but when I put the two codes together the code doesn't compile.

I did some tests:

  1. I tried to just import pywhatkit as pwk in the flask application;

  2. I tried to use the code in another python file and import;

  3. I tried to put both codes together in same python file.

In all situations the code does not compile, when I debug the code for test 1, I get the following error:

Exception has occurred: SystemExit 3
  File "C:\Users\diego\codes\Working\modify.py", line 96, in <module>
    app.run(debug=True)

Why can't I compile my code when I put the pywhatkit library inside the flask application?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷爱 2025-02-14 18:06:19

对于所有遇到类似问题的人,我能够通过安装 pywhkit 版本5.0来解决它。

For all of you who have a similar problem, I was able to solve it by installing pywhatkit version 5.0.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文