얘들 아, 난 그냥urllib2가, 구글 앱 엔진, 그리고 유니 코드 질문
나의 현재의 곤경이입니다 ... 그래서 나는 문제의 무리 실행 해요 구글 앱 엔진을 배우고 야. 데이타베이스가 있습니다.
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()
그리고 제가 가지고있는 문제는 content 속성에 있습니다.
> 500 바이트가 넘는 웹 페이지의 내용을 저장해야하므로 db.TextProperty()를 사용하고 있습니다.
내가 실행중인 문제는 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)
네, 맞아요. – shawn
readline을 만들고 데이터 저장소에 넣은 스 니펫을 추가 할 수 있습니까? – systempuntoout