我是靠谱客的博主 美好音响,这篇文章主要介绍python3 如何将list列表中循环输出中文正常显示,现在分享给大家,希望可以做个参考。

python3 如何将list列表中循环输出中文正常显示

from selenium import webdriver
from time import sleep
driver = webdriver.Firefox()
list = [“疫情”,“demo”,“1”]
driver.get(“https://www.baidu.com/”)
for i in list:
i=i.decode(‘utf-8’)
driver.find_element_by_xpath(’//*[@id=“kw”]’).clear()
driver.find_element_by_id(‘kw’).send_keys(i)
sleep(1)
driver.find_element_by_id(‘su’).click()
sleep(1)
driver.quit()

不写decode(‘utf-8’) 就会报错UnicodeDecodeError: ‘utf8’ codec can’t decode byte 0xe7 in position 0: unexpected end of data 错误显示;

最后

以上就是美好音响最近收集整理的关于python3 如何将list列表中循环输出中文正常显示的全部内容,更多相关python3内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(51)

评论列表共有 0 条评论

立即
投稿
返回
顶部