gpt4 book ai didi

python - 在python中输出表情符号

转载 作者:行者123 更新时间:2023-11-28 19:29:21 24 4
gpt4 key购买 nike

我正在尝试使用 python 库 pyautoguiTelegram 中自动输出表情符号,但是我发现不可能只是 typewrite 它。我搜索了库来帮助我解决我的问题,我找到了 pyemojifyemoji 但在这两种情况下我都遇到了

UnicodeEncodeError: 'charmap' codec can't encode characters: character maps to <undefined>

代码是:

from pyemojify import emojify
print(emojify("Life is short :smile: , use :sparkles: Python :sparkles:"))

还有这个:

import emoji
print(emoji.emojize('Python is :thumbs_up_sign:'))

我在这里搜索了很多,但最终没有一个答案对我有用。现在我有两个问题:有什么方法可以使用 python pyautogui 或者甚至使用 java Robot 类在 Telegram 中输出表情符号?第二个问题是我应该如何修复我的代码中的 UnicodeEncodeError?提前致谢:)

最佳答案

from selenium import webdriver

b = webdriver.Firefox()
b.get('https://web.telegram.org')
....
....
b.find_elements_by_class_name('composer_rich_textarea')[0].send_keys('\U0001F422')
print('\U0001F422'.encode('utf-8'))

关于python - 在python中输出表情符号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33877553/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com