Python 此代码查看html结果无

Python 此代码查看html结果无,python,urllib,Python,Urllib,我编写了代码视图html,但没有结果 # coding: UTF-8 import urllib class View_html: def __init__(self): url = "http://www.yahoo.com/" self.data = urllib.urlopen(url) def html(self): self.data.read() if __name__=="__main__": a =

我编写了代码视图html,但没有结果

# coding: UTF-8

import urllib

class View_html:
    def __init__(self):
        url = "http://www.yahoo.com/"
        self.data = urllib.urlopen(url)

    def html(self):
        self.data.read()

if __name__=="__main__":
    a = View_html()
    print a.html()
结果

None

如何更改此代码?

您忘记了
return
关键字:

def html(self):
    return self.data.read()