python2.7 爬虫中文显示错误

xiaoxiao2021-02-28  98

import:BeautifulSoup,selenium

text1 = soup.find(class_='hot_recommend').find_all('p') print(text) 输出的text是/u开头字符串

以为是编码的原因

最后发现只要把text分行输出即可

for text in text1: text_w = str(text) #text_w.encode('utf-8') print(text_w) f.write(text_w) f.write("\n") print("Write over~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")

转载请注明原文地址: https://www.6miu.com/read-30015.html

最新回复(0)