gpt4 book ai didi

python - 谷歌应用引擎 + python : uploading to blobstore causes wrong encoding

转载 作者:太空宇宙 更新时间:2023-11-04 03:45:39 24 4
gpt4 key购买 nike

我尝试使用以下 HTML 表单将 blob 上传到 Google App Engine 的 blobstore:

<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8>
</head>
<body>
<form id=upload action={{upload_url}} method=post enctype=multipart/form-data>
Name: <input type=text name=name>
Your photo: <input type=file name=image required=required><br><br>
<input type=submit value=submit>
</form>
</body>
</html>

模板变量{{upload_url}}的值在服务器端通过upload_url = blobstore.create_upload_url('/upload')获取。后期处理脚本如下:

    class Test(ndb.Model):
name = StringProperty()
image = StringProperty()

test = Test()
test.name = self.request.get('name')
image = self.get_uploads('image')[0]
test.image = str(image.key())
test.put()

通常,name 字段会填入非英文字符(例如,中文)。以上程序在我的本地 SDK 上运行良好。但是,当程序在 Google App Engine 上运行时,name 编码不正确。那有什么问题呢?

最佳答案

您不必在元标记参数周围加上引号:<meta charset="UTF-8"> ?另外,尝试:<meta http-equiv="content-type" content="text/html; charset=utf-8" /> .并且,确保您以 UTF-8 编码保存模板的文本文档。

关于python - 谷歌应用引擎 + python : uploading to blobstore causes wrong encoding,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23956364/

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