开发者

problem with urlopen

开发者 https://www.devze.com 2023-03-24 08:25 出处:网络
This code used to print out a web page.It now prints a single space, even though that page clearly has con开发者_如何学Ctent when viewed in a browser

This code used to print out a web page. It now prints a single space, even though that page clearly has con开发者_如何学Ctent when viewed in a browser

from urllib.request import urlopen
f = urlopen('http://online.wsj.com/mdc/public/page/2_3020-tips.html?mod=topnav_2_3000')
page = f.read()
f.close()
print('*', page.decode(), '*')

This started when I upgraded from 3.2 to 3.2.1, but that could just be a coincidence

What obvious thing am I missing?


It works in Python 3.1 and Python 3.2, but not Python 3.2.1 (it returns an empty string).

EDIT: I've reported it in the Python-Dev list.

0

精彩评论

暂无评论...
验证码 换一张
取 消