使用 urllib.open 时出现 Python 错误 [英] Python error when using urllib.open

查看:26
本文介绍了使用 urllib.open 时出现 Python 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我运行这个时:

import urllib

feed = urllib.urlopen("http://www.yahoo.com")

print feed

我在交互式窗口 (PythonWin) 中得到这个输出:

I get this output in the interactive window (PythonWin):

<addinfourl at 48213968 whose fp = <socket._fileobject object at 0x02E14070>>

我期待获得上述 URL 的来源.我知道这在其他计算机(如学校的计算机)上有效,但这是在我的笔记本电脑上,我不确定这里的问题是什么.另外,我根本不明白这个错误.这是什么意思?添加信息?fp?请帮忙.

I'm expecting to get the source of the above URL. I know this has worked on other computers (like the ones at school) but this is on my laptop and I'm not sure what the problem is here. Also, I don't understand this error at all. What does it mean? Addinfourl? fp? Please help.

推荐答案

试试这个:

print feed.read()

此处查看 Python 文档.

See Python docs here.

这篇关于使用 urllib.open 时出现 Python 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆