<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<STYLE type=text/css> <!--@import url(D:\Program Files\NeteaseMail\Netease\网易闪电邮\\data\scrollbar.css); --></STYLE>
<META content="text/html; charset=utf-8" http-equiv=Content-Type>
<STYLE>BLOCKQUOTE{margin-Top: 0px; margin-Bottom: 0px; margin-Left: 2em}; </STYLE>
<META name=GENERATOR content="MSHTML 8.00.7600.16766"><BASE
target=_blank></HEAD>
<BODY
style="BORDER-RIGHT-WIDTH: 0px; MARGIN: 12px; BORDER-TOP-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px"
marginheight="0" marginwidth="0">
<DIV>
<DIV><FONT color=#000000 size=3 face=宋体>Dear friends:</FONT></DIV>
<DIV><FONT color=#000000 size=3 face=宋体></FONT> </DIV>
<DIV><FONT color=#000000 size=3 face=宋体>I got a import error when I use Python
3.2 to import BeautifulSoup 3.2.0 .</FONT></DIV>
<DIV><FONT face=宋体>Is there any differences between Python 3.2 and other
version? This is my first time to use Python3.2 .</FONT></DIV>
<DIV><FONT color=#000000 size=3 face=宋体>And the error message will be as
below.</FONT></DIV>
<DIV><FONT color=#000000 size=3 face=宋体></FONT> </DIV>
<DIV><FONT color=#000000 size=3 face=宋体></FONT> </DIV>
<DIV><FONT color=#000000 size=3 face=宋体>>>> from BeautifulSoup import
BeautifulSoup<BR>Traceback (most recent call last):<BR> File
"<pyshell#2>", line 1, in <module><BR> from
BeautifulSoup import BeautifulSoup<BR> File
"C:\Python32\BeautifulSoup.py", line 448<BR> raise
AttributeError, "'%s' object has no attribute '%s'" % (self.__class__.__name__,
attr)<BR>
^<BR>SyntaxError: invalid syntax</FONT></DIV>
<DIV><FONT face=宋体></FONT> </DIV>
<DIV><FONT face=宋体></FONT> </DIV>
<DIV><FONT face=宋体></FONT> </DIV>
<DIV><FONT face=宋体>And the error place point to BeautifulSoup</FONT></DIV>
<DIV><FONT face=宋体></FONT> </DIV>
<DIV><FONT face=宋体>class NavigableString(unicode, PageElement):</FONT></DIV>
<DIV><FONT face=宋体> def __new__(cls,
value):<BR> """Create a new
NavigableString.</FONT></DIV>
<DIV><FONT face=宋体> When unpickling a
NavigableString, this method is called
with<BR> the string in
DEFAULT_OUTPUT_ENCODING. That encoding needs to
be<BR> passed in to the superclass's
__new__ or the superclass won't
know<BR> how to handle non-ASCII
characters.<BR>
"""<BR> if isinstance(value,
unicode):<BR>
return unicode.__new__(cls, value)<BR>
return unicode.__new__(cls, value, DEFAULT_OUTPUT_ENCODING)</FONT></DIV>
<DIV><FONT face=宋体> def
__getnewargs__(self):<BR> return
(NavigableString.__str__(self),)</FONT></DIV>
<DIV><FONT face=宋体> def __getattr__(self,
attr):<BR> """text.string gives you
text. This is for backwards<BR>
compatibility for Navigable*String, but for CData* it lets
you<BR> get the string without the
CData wrapper."""<BR> if attr ==
'string':<BR>
return self<BR> else:<BR><STRONG><FONT
color=#ff0000>
raise AttributeError, "'%s' object has no attribute '%s'" %
(self.__class__.__name__, attr)</FONT></STRONG></FONT></DIV>
<DIV><FONT face=宋体> def
__unicode__(self):<BR> return
str(self).decode(DEFAULT_OUTPUT_ENCODING)</FONT></DIV>
<DIV><FONT face=宋体> def __str__(self,
encoding=DEFAULT_OUTPUT_ENCODING):<BR>
if
encoding:<BR>
return self.encode(encoding)<BR>
else:<BR>
return self</FONT></DIV>
<DIV><FONT face=宋体></FONT> </DIV>
<DIV><FONT face=宋体></FONT> </DIV>
<DIV><FONT face=宋体>Did I make any mistake?</FONT></DIV>
<DIV><FONT face=宋体>How can I do this correctly?</FONT></DIV>
<DIV><FONT face=宋体></FONT> </DIV>
<DIV><FONT face=宋体></FONT> </DIV>
<DIV><FONT color=#000000 size=3 face=宋体></FONT> </DIV>
<DIV align=left><FONT color=#c0c0c0 size=2
face=Verdana>2011-05-06</FONT></DIV><FONT size=2 face=Verdana>
<HR style="WIDTH: 122px; HEIGHT: 2px" align=left SIZE=2>
<DIV><FONT color=#c0c0c0 size=2 face=Verdana><SPAN
id=_FlashSignName>Kerry</SPAN></FONT></DIV></FONT></DIV></BODY></HTML>