gpt4 book ai didi

python - 是什么导致列表索引超出范围?

转载 作者:可可西里 更新时间:2023-11-01 16:31:04 25 4
gpt4 key购买 nike

<分区>

我在处理表单和升级后回到基础方面遇到了一些问题我无法让最小的示例工作:

class PhotoUploadFormHandler(webapp2.RequestHandler):
def get(self):
self.response.out.write('<html><body>')
self.response.out.write('<form action="%s" method="POST" enctype="multipart/form-data">' % blobstore.create_upload_url('/upload_photo'))
self.response.out.write('''Upload File: <input type="file" name="file"><br> <input type="submit"
name="submit" value="Submit"> </form></body></html>''')

class PhotoUploadHandler(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
try:
upload = self.get_uploads()[0]
user_photo = UserPhoto(user=users.get_current_user(),
blob_key=upload.key())
db.put(user_photo)
self.redirect('/view_photo/%s' % upload.key())

except Exception, ex:
self.response.out.write(str(ex))

app = webapp2.WSGIApplication([

('/upload_form', PhotoUploadFormHandler),
('/upload_photo', PhotoUploadHandler),

以上返回访问上传文件时的异常:

list index out of range

为什么?谢谢你的帮助。

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com