使用Python及selenium操作网页,出现中文时,比如填写表单
element.send_keys('中国')
可能会出现UnicodeDecodeError: ‘utf8’ codec can’t decode错误
解决方法如下:
'中国'.decode('gb18030')
本文介绍使用Python和Selenium进行网页操作时遇到UnicodeDecodeError的常见原因,并提供了一种有效的解决方案,即通过指定正确的字符集来避免此类错误。
使用Python及selenium操作网页,出现中文时,比如填写表单
element.send_keys('中国')
可能会出现UnicodeDecodeError: ‘utf8’ codec can’t decode错误
解决方法如下:
'中国'.decode('gb18030')

被折叠的 条评论
为什么被折叠?