みんな、私はちょうどurllib2の、Google App Engineの、およびUnicodeの質問
私の現在の苦境はこれです...ので、私は問題の束に実行しているGoogleのアプリエンジンを学んでいますねえ。私はデータベースを持っています。
class Website(db.Model):
web_address = db.StringProperty()
company_name = db.StringProperty()
content = db.TextProperty()
div_section = db.StringProperty()
local_links = db.StringProperty()
absolute_links = db.BooleanProperty()
date_updated = db.DateTimeProperty()
私はコンテンツプロパティを持っています。
私はdb.TextProperty()を使用しています。なぜなら、> 500バイトを持つWebページのコンテンツを格納する必要があるからです。
私が問題に遭遇しているのは、urllib2.readlines()のフォーマットです。 TextProperty()に入れると、ASCIIに変換されます。いくつかの文字は> 128であり、UnicodeDecodeErrorをスローします。
これを回避する簡単な方法はありますか?ほとんどの部分については、私はそれらの文字を気にしない...
私のエラーは次のとおりです。
Traceback (most recent call last):
File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/webapp/init.py", line 511, in call handler.get(*groups) File "/base/data/home/apps/game-job-finder/1.346504560470727679/main.py", line 61, in get x.content = website_data_joined File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/init.py", line 542, in set value = self.validate(value) File "/base/python_runtime/python_lib/versions/1/google/appengine/ext/db/init.py", line 2407, in validate value = self.data_type(value) File "/base/python_runtime/python_lib/versions/1/google/appengine/api/datastore_types.py", line 1006, in new return super(Text, cls).new(cls, arg, encoding) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 2124: ordinal not in range(128)
私はASCIIにUnicodeを変換すると、「エンコーディング」ではない「デコードだろうと思っているだろう"あなたはそれが他の方法ではないと確信していますか? –
うん、そうだよ。 – shawn
readlineを作成してデータストアを置くスニペットを追加できますか? – systempuntoout