“假冒(行尾)”表示您的图案以反斜杠结尾。这与Tkinter无关。您可以在交互式外壳中轻松地复制错误:
>>> import re>>> pattern="foobar\">>> re.search(pattern, "foobar")Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/Library/frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py", line 142, in search return _compile(pattern, flags).search(string) File "/Library/frameworks/Python.framework/Versions/2.5/lib/python2.5/re.py", line 241, in _compile raise error, v # invalid expressionsre_constants.error: bogus escape (end of line)
解决方案?确保您的模式不以单个反斜杠结尾。