【发布时间】:2012-02-10 05:35:03
【问题描述】:
我正在创建一个用户可以输入一段文本的应用程序,我在该段落上运行拼写检查。通过打开包含我的字典的文件'words.txt',我已经在本地文档中很容易地实现了这一点。我试图弄清楚如何打开一个单词列表来实现我的拼写检查。
我的第一次尝试是将它作为静态文件放在我的目录中并获取该文件,但我不断收到错误。
这是我的文件:
app.yaml:
application: *******
version: 1
runtime: python
api_version: 1
handlers:
- url: /(.*\.txt)
mime_type: text/plain
static_files: static/\1
upload: static/(.*\.txt)
- url: /.*
script: helloworld.py
摘自 helloworld.py
import os
from google.appengine.ext.webapp import template
import cgi
import datetime
import urllib
import wsgiref.handlers
from google.appengine.api import urlfetch
from google.appengine.ext import db
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
....
result=urlfetch.fetch(os.path.join(os.path.dirname(__file__),'words.txt'))
words=set(result.splitlines())
怎么了?我不断收到错误消息。
【问题讨论】: