我如何对此进行编码并用pywhatkit打印消息

发布于 2025-01-23 12:03:39 字数 921 浏览 1 评论 0原文

我正在尝试使用pywhkit自动化一些whatsapp消息,但是有一些错误:在bellow中,变量消息仅在类型为str时才打印,如果我添加.encode('utf-8),则它将更改为字节而且我不知道如何组织它,我已经考虑了很多想法,但是它行不通,您不能对串联的字符串提出重音吗?如果我只发送无变量的消息,则可以正常工作。

def send():
today = get_date()
for day in range(30):
    text_today = date.today().strftime("%B %d, %Y")
    print(f"Today is: {text_today}" )
    if today >=6:
        print("is the weekend!")
    else:
        not = get_article()
        menssage = str(' *¡Hi, Community!* Here are 5 articles in which you can find valuable content:\n\n -' + not + '\n').encode('utf-8') #error here
        print(type(mensaje))
        pywhatkit.sendwhatmsg_to_group("###############", message, 17, 50, 20, True, 3)
        print("message sent")

这样的工作:

message = "¡hello there!".encode(utf-8)
pywhatkit.sendwhatmsg_to_group("###############", message, 17, 50, 20, True, 3)

我可以做些什么? - 对不起,找不到标签pywhkit。

i'm trying to automate some whatsapp messages with pywhatkit, but have some errors: in the code bellow, the variable message only print when the type is str, if if I add .encode('utf-8) then it changes to bytes and I don't know how to organize it, I have given it a lot of thought but it doesn't works, can't you put an accent to concatenated strings? if I just send a message without variables it works.

def send():
today = get_date()
for day in range(30):
    text_today = date.today().strftime("%B %d, %Y")
    print(f"Today is: {text_today}" )
    if today >=6:
        print("is the weekend!")
    else:
        not = get_article()
        menssage = str(' *¡Hi, Community!* Here are 5 articles in which you can find valuable content:\n\n -' + not + '\n').encode('utf-8') #error here
        print(type(mensaje))
        pywhatkit.sendwhatmsg_to_group("###############", message, 17, 50, 20, True, 3)
        print("message sent")

works like this:

message = "¡hello there!".encode(utf-8)
pywhatkit.sendwhatmsg_to_group("###############", message, 17, 50, 20, True, 3)

there's something i can do? -- sorry cant find the tag pywhatkit.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文