解决了IDE中文显示的问题,通过print(soup.head.title).encode('gb18030')解决了中文路径无法打开的问题。
通过file=open(u"D:/users/nancy/share/sae6depart/6系资料/python/crawl.txt","w")。
import urllib
from urllib import urlopen
c=urllib.urlopen("http://www.baidu.com")
contents=c.read()
print(contents[0:50])
from bs4 import BeautifulSoup
soup=BeautifulSoup(urlopen("http://www.baidu.com"))
print(soup.head.title).encode('gb18030')
file=open(u"D:/users/nancy/share/sae6depart/6系资料/python/crawl.txt","w")
好了现在开始正式的=================================================================
首先,主要参考物:
http://download.youkuaiyun.com/detail/u012365383/6986983 (Python自然语言处理)

博客内容涉及解决IDE中文显示和中文路径问题,为NLP学习铺平道路。通过Python进行文件操作,并引用了多个资源,包括Python自然语言处理、网络爬虫和文本挖掘的相关教程。
最低0.47元/天 解锁文章
811

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



