On 31 Dec 2006 05:20:10 -0800, JTree <[EMAIL PROTECTED]> wrote:
> def funUrlFetch(url):
>     lambda url:urllib.urlopen(url).read()

This function only creates a lambda function (that is not used or
assigned anywhere), nothing more, nothing less. Thus, it returns None
(sort of "void") no matter what is its argument. Probably you meant
something like

def funUrlFetch(url):
    return urllib.urlopen(url).read()

or

funUrlFetch = lambda url:urllib.urlopen(url).read()


> objUrl = raw_input('Enter the Url:')
> content = funUrlFetch(objUrl)

content gets assigned None. Try putting "print content" before the unicode line.

> content = unicode(content,"gbk")

This, equivalent to unicode(None, "gbk"), leads to

> TypeError: coercing to Unicode: need string or buffer, NoneType found

None's are not strings nor buffers, so unicode() complains.

See ya,

-- 
Felipe.
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to