selenium自动输入特殊表情符号报错:selenium.common.exceptions.WebDriverException: Message: unknown error: ChromeDriver only supports characters in the BMP

最近在利用selenium调用chatgpt时报错:selenium.common.exceptions.WebDriverException: Message: unknown error: ChromeDriver only supports characters in the BMP。

由于我的应用场景是不需要表情符号的,所以考虑简单粗暴去除表情符号避开这个问题。

一个常用的库是emoji,它提供了一些有用的函数来处理和删除表情符号。

首先,我们需要安装该库。可以使用以下命令来安装emoji库:

pip install emoji

我们可以导入emoji库并使用其中的demojize函数来去除特殊表情符号。

示例如下:

import emoji

text = "I like Python! 😊❤️🐍"
clean_text = emoji.demojize(text)
print(clean_text)

关注公众号“大模型全栈程序员”回复“小程序”获取1000个小程序打包源码。更多免费资源在http://www.gitweixin.com/?p=2627

发表评论

邮箱地址不会被公开。 必填项已用*标注