A question about unicode() function
- From: "JTree" <eastera@xxxxxxxxx>
- Date: 31 Dec 2006 05:20:10 -0800
Hi,all
I encountered a problem when using unicode() function to fetch a
webpage, I don't know why this happenned.
My codes and error messages are:
Code:
#!/usr/bin/python
#Filename: test.py
#Modified: 2006-12-31
import cPickle as p
import urllib
import htmllib
import re
import sys
def funUrlFetch(url):
lambda url:urllib.urlopen(url).read()
objUrl = raw_input('Enter the Url:')
content = funUrlFetch(objUrl)
content = unicode(content,"gbk")
print content
content.close()
error message:
C:\WINDOWS\system32\cmd.exe /c python test.py
Enter the Url:http://www.msn.com
Traceback (most recent call last):
File "test.py", line 16, in ?
content = unicode(content,"gbk")
TypeError: coercing to Unicode: need string or buffer, NoneType found
shell returned 1
Hit any key to close this window...
Any suggestions would be appreciated!
Thanks!
.
- Follow-Ups:
- Re: A question about unicode() function
- From: Felipe Almeida Lessa
- Re: A question about unicode() function
- Prev by Date: Re: Are all classes new-style classes in 2.4+?
- Next by Date: py2exe 0.6.6 released
- Previous by thread: Are all classes new-style classes in 2.4+?
- Next by thread: Re: A question about unicode() function
- Index(es):
Relevant Pages
|