这是一个创建于 4448 天前的主题,其中的信息可能已经有所发展或是发生改变。
我定义了一个视图用于处理post过来的ajax请求
def upload(request):
url = request.POST.get('image_url')
ats = request.POST.get('check')
ok = renren_upload(request.session['session_key'],url,ats)
return httpResponse(unicode(str(ok)))
其中ok是另外一个函数的返回值,是0和1
但是老是不成功,提示
UnicodeDecodeError at /upload/
'ascii' codec can't decode byte 0xff in position 2: ordinal not in range(128)
我试图把ok转化为unicode也不行啊。。。。
这是为啥呢?
5 条回复 • 1970-01-01 08:00:00 +08:00
|
|
1
suckli 2012-08-01 19:31:54 +08:00
unicode(str(ok)) 这一句有问题,应该是str(ok)的时候出错的 记住 在python里面只有两种编码 str和unicode 试试把str(ok)这个抓换去掉
|
|
|
3
keakon 2012-08-01 20:00:25 +08:00
先确定是不是unicode(str(ok))出错,再看看ok是什么…
|
|
|
4
suckli 2012-08-01 20:36:54 +08:00
把可以的数值用type()打印出来 你确定ok是整数0,1吗? @ stackpop
|
|
|
5
fanzeyi 2012-08-01 20:38:57 +08:00
试试
unicode(str(int(ok))) ....
= =
其实我觉得 unicode(int(ok)) 就够了..
|