Wednesday, 2 October 2013

Python, replace long dash with short dash?

Python, replace long dash with short dash?

In python, I am trying to figure out how to replace strings with " – "
with " - ". The first one is a long dash, while the second one is a long
dash.
If I do something like:
If " – " in string:
string = string.replace(" – ", " - ")
then I get the following error:
SyntaxError: Non-ASCII character '\xe2' in file ./script.py on line 76,
but no encoding declared; see http://www.python.org/peps/pep-0263.html for
details
How can I fix this? Line 76 that the error is pointing to is my "If"
statement up there.

No comments:

Post a Comment