我希望能够在Python 3.4.3中读取HTML文件。
我尝试过以下方法:
import urllib.request
fname = r"C:\Python34\html.htm"
HtmlFile = open(fname,'w')
print (HtmlFile)
这将打印:
<_io.TextIOWrapper name='C:\\Python34\\html.htm' mode='w' encoding='cp1252'>
我想获取HTML源代码,以便使用beautiful soup进行解析。
open(fname, 'w')
=>open(fname, 'r')
. - m02ph3u5