Try adding the import to the very top of your file (after any #!/usr/bin/python2.x
statements).
Python - Can't import with_statement from __future__
-
28-06-2022 - |
题
Here are the other imports already in my app
import os
import sys
from google.appengine.ext.webapp import template
import cgi
import urllib
import wsgiref.handlers
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
from google.appengine.api import mail
from django.utils import simplejson as json
from datetime import datetime
import random
import string
from google.appengine.ext import blobstore
from google.appengine.ext.webapp import blobstore_handlers
from google.appengine.api import files
Everything compiles and works fine.
But when I add this import:
from __future__ import with_statement
nothing works. I go to appspot, and the page just says "server error."
How can I successfully import with_satement
?
EDIT:
I I know blobstore
is deprecated. with
is used with blobstore
. Could that be what's causing the problem? But with
isn't only used with blobstore
...
解决方案
其他提示
from __future__ imports must occur at the beginning of the file
不隶属于 StackOverflow