我正在编写一个相当简单的代码,通过Python发送WhatsApp消息,我需要使用换行符
例如,如果消息是“亲爱的学生,请发送您的报告,感谢您的关注”
WhatsApp上的消息应该是这样的
Dear Student,
Please send your report
Thank you for your attention
使用\n的尝试无效。文本必须在单个消息中。下面的代码,我已经先进,提前感谢您的帮助
# Necessary libraries
import pyautogui as pg
import webbrowser as web
import time
message = "Dear Student, \n Please send your report\n Thank you for your attention"
number = 'XX_XXXXXXXXX'
web.open("https://web.whatsapp.com/send?phone="+number+"&text="+message)
time.sleep(12) # wait for the page to load
pg.click(1335, 690) # click on the submit button location
对消息使用urlencodedtext,因为它是http请求, 因此,你的信息是
Check this question first
您可以使用任何适合您的方式。
也许以下方法也适用于您。
更新:必须使用以下方式
或者可以尝试使用f或.format字符串使其变得简单。
可以在下面的链接中阅读我的另一个答案,以了解有关WhatsApp web使用python的更多信息
How do I read whatsapp messages from a contact using python?
我正在使用python开发WhatsApp机器人
有关贡献,请联系:anurag。cse016@gmail.com
如果这个答案对你有帮助,请在我的https://github.com/4NUR46上加一颗星
相关问题 更多 >
编程相关推荐