0
我試圖導入CSV字符串到我在Django模型,它不斷拋出編碼字符串在Django/Python的
'ascii' codec can't encode character u'\xe9' in position 29: ordinal not in range(128)
這裏是我當前視圖代碼的形式郵寄。
def saveLoot(request):
if 'q' in request.POST:
scsv = request.POST['q']
f = StringIO.StringIO(scsv)
reader = csv.reader(f, delimiter=',')
for row in reader:
user = UserProfile.objects.get(character=row[3])
loot = Loot(loot_id=row[0], item_name=row[1], source=row[2], winner=user, loot_type=row[4], lockout_tier=row[5], time=row[6], date=row[7])
loot.save()
message = "I like pie, it's good, and guess what. I've saved that for you."
else:
message = 'Fill the damn box in will you.'
return HttpResponse(message)
好像在那裏我試圖從口音的用戶配置模型人物拉用戶不正確編碼迫使這個錯誤。
我知道這可能是非常基本的東西,我試過設置默認編碼,自從我上次查看python(近12個月)以來已經有一段時間了。