<p>看起来字符串常量中的内容不是用<code>cp1252</code>编码的字节字符串,这是使<code>str.isalpha</code>在您的语言环境中正常工作所必需的。你不会说是在什么环境下打的。我可以从<code>locale</code>响应的方式看出您在Windows上;也许您是从某个IDE获得<code>UTF-8</code>,或者从命令提示符窗口获得<code>cp850</code>。</p>
<p>你在屏幕上看到的通常对调试没有什么帮助。你所看到的不是你所拥有的。内置函数是(或希望是)您的朋友。它将用ASCII清楚地显示您实际拥有的内容。[Python 3:<code>repr</code>被重命名为<code>ascii</code>,并且有一个新的<code>repr</code>,这不是您想要的]</p>
<p>尝试键入<code>s = "your string constant with 'accented' letters"</code>,然后<code>print repr(s)</code>,然后编辑问题以显示结果(复制/粘贴,不要重新键入)。还要说明您正在使用的Python版本。</p>
<p>另一个可能的朋友是“unicodedata.name”。。。见下文。</p>
<pre><code>>>> import locale
>>> locale.setlocale(locale.LC_ALL, 'Finnish')
'Finnish_Finland.1252'
>>> s = '\xe4\xf6\xe5'
>>> import unicodedata
>>> for c in s:
... u = c.decode('1252')
... print repr(c), repr(u), unicodedata.name(u, '<no name>')
...
'\xe4' u'\xe4' LATIN SMALL LETTER A WITH DIAERESIS
'\xf6' u'\xf6' LATIN SMALL LETTER O WITH DIAERESIS
'\xe5' u'\xe5' LATIN SMALL LETTER A WITH RING ABOVE
>>> s.isalpha()
True
</code></pre>
<p>您可以将以上结果与<a href="http://en.wikipedia.org/wiki/Windows-1252" rel="nofollow">this chart</a>进行比较。</p>