App Engine gives error in number formatting when deployed
I have just deployed my app and as soon as I go on the homepage I get the '500 internal server error' page. Having looked through the logs I got the following error:
type 'exceptions.SyntaxError'>: Non-ASCII character '\xc2' in file /base/data/home/apps/spare-wheels/1.348259065130939449/sparewheels.py on line 465, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details (sparewheels.py, line 465)
The line in question looks like this:
self.template_values['price_pounds'] = "£%.2f" % (float(self.event.price_pence)/100)
This worked fine when running on localhost: is there something about number formatting that the Google Apps version of Pytho开发者_JAVA技巧n doesn't support?
Check the encoding of the python file, is it UTF-8? That error message suggests you may have saved the file as an ASCII format with international characters in the file (aka "£") causing Google's python runtime to barf up that 500 error.
Also try tossing this line on the first or second line of the python file:
# coding=utf-8
If you don't want to muck with file encodings as @Shakakai suggests, and that's the only non-ASCII character you're dealing with in your source, you could also just replace that character with the equivalent HTML entity £
, which will render out correctly.
精彩评论