both tow are unicode,but when compare,it doesn't workï¼
<pre><code># -*- coding: utf-8 -*- 
from bs4 import  BeautifulSoup 
import urllib2

response = urllib2.urlopen('http://bbs.szhome.com/80300-0-0-0-3005.html')
html = response.read()

soup = BeautifulSoup(html)

returntext = soup.find('dl',class_='fix').text 
print returntext

if isinstance(returntext,unicode):
    print 'ok1' #true,print ok1

text = u'ææ ç¸å³æ°æ®...'

if isinstance(text,unicode):
    print 'ok2' #true,print ok2

text2 = 'ææ ç¸å³æ°æ®...'
if isinstance(text2,str):
    print 'ok3' #true,print ok3

if returntext == text:
    print 'ok4' #both unicode,but not excute,why?
</code></pre>

<p>You need to <a href="https://docs.python.org/2/library/string.html#string.strip" rel="nofollow">strip</a> all newlines before comparison:</p>

<pre><code>&gt;&gt;&gt; print returntext

ææ ç¸å³æ°æ®...

&gt;&gt;&gt; print text
ææ ç¸å³æ°æ®...
&gt;&gt;&gt; returntext
u'\n\u6682\u65e0\u76f8\u5173\u6570\u636e...\n'
&gt;&gt;&gt; text
u'\u6682\u65e0\u76f8\u5173\u6570\u636e...'
&gt;&gt;&gt; returntext.strip() == text
True
</code></pre>

python unicode