我在gae中有一段python代碼。AttributeError:'unicode'對象沒有'pop'屬性
def post(self):
cases=self.request.get('cases')
while cases:
logging.info("cases: %s " % cases)
case=cases.pop()
哪個產生這個日誌。
INFO 2012-09-19 20:23:50,690 views.py:674] cases: [u'court1150']
ERROR 2012-09-19 20:23:50,690 webapp2.py:1553] 'unicode' object has no attribute 'pop'
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1536, in __call__
rv = self.handle_exception(request, response, e)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1530, in __call__
rv = self.router.dispatch(request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1278, in default_dispatcher
return route.handler_adapter(request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 1102, in __call__
return handler.dispatch()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 572, in dispatch
return self.handle_exception(e, self.app.debug)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/webapp2/webapp2.py", line 570, in dispatch
return method(*args, **kwargs)
File "/Users/brian/googleapps/scheduler/views.py", line 675, in post
case=cases.pop()
AttributeError: 'unicode' object has no attribute 'pop'
另一方面,在交互式控制檯中使用這個幾乎相同的代碼。
cases = [u'court1150']
while cases:
case=cases.pop()
print case
print cases
我沒有收到任何錯誤,下面打印出來。
court1150
[]
爲什麼我在gae啓動器中出現unicode錯誤,我該如何解決它?
好吧,很顯然這是不相同的,因爲'cases'是不同類型的。 – Hamish