我得到“服务器遇到错误,无法完成您的请求”错误

时间:2011-03-15 14:29:28

标签: python google-app-engine encoding

我的谷歌应用引擎中出现“服务器遇到错误但无法完成您的请求”错误:

我的app.yaml:

application: myapp
version: 2
runtime: python
api_version: 1

builtins:
- remote_api: on
- datastore_admin: on

handlers:
- url: /AJAX
  script: main.py

- url: /emailtrigger
  script: main.py

- url: /emailworker
  script: main.py

- url: /
  static_files: static_files/index.html
  upload: static_files

- url: /
  static_dir: static_files
日志中的

错误:

<type 'exceptions.SyntaxError'>: Non-ASCII character '\xc3' in file /base/data/home/apps/myapp/2.349019521625775975/main.py on line 77, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details (main.py, line 77)

我有一个字符串:ã; main.py是utf-8编码的

1 个答案:

答案 0 :(得分:2)

  1. 尝试将其添加为代码的第一行
  2. # - - 编码:utf-8 - -

    1. 尝试将字符串转换为unicode

      self.response.out.write(UNICODE( “A”, “UTF-8”))