UnicodeDecodeError 急需各位帮忙

UnicodeDecodeError at /supe/resolveTask/newSample/1,/
'utf8' codec can't decode byte 0xa4 in position 945: unexpected code byteRequest Method: GET
Request URL: http://127.0.0.1:8000/supe/resolveTask/newSample/1,/
Django Version: 1.2.3
Exception Type: UnicodeDecodeError
Exception Value: 'utf8' codec can't decode byte 0xa4 in position 945: unexpected code byte
Exception Location: D:\Python25\lib\encodings\utf_8.py in decode, line 16
Python Executable: D:\Python25\python.exe
Python Version: 2.5.4
Python Path: ['E:\\supe', 'C:\\windows\\system32\\python25.zip', 'D:\\Python25\\DLLs', 'D:\\Python25\\lib', 'D:\\Python25\\lib\\plat-win', 'D:\\Python25\\lib\\lib-tk', 'D:\\Python25', 'D:\\Python25\\lib\\site-packages', 'D:\\Python25\\lib\\site-packages\\win32', 'D:\\Python25\\lib\\site-packages\\win32\\lib', 'D:\\Python25\\lib\\site-packages\\Pythonwin', 'D:\\Python25\\lib\\site-packages\\wx-2.9.1-msw']
Server time: Mon, 13 Jun 2011 17:39:33 +0800


Unicode error hint
The string that could not be encoded/decoded was: ????1?7 //1

Traceback:
File "D:\Python25\Lib\site-packages\django\core\handlers\base.py" in get_response
  100.                     response = callback(request, *callback_args, **callback_kwargs)
File "E:\supe\..\supe\resolveTask\views.py" in newSample
  524.         return render_to_response('resolveTask/newSample.htm', {'action':'/supe/resolveTask/newSampleSubmit/', 'type':type, 'tasklist':tasklist, 'selectedTaskName':selectedTaskName, 'samplelist':samplelist, 'sampleID':sampleID, 'selectedSampleID':selectedSampleID, 'runMode':runMode, 'startSupeServerFlag':startSupeServerFlag, 'processes':processes, 'runTimes':runTimes, 'deployDir':deployDir, 'setNodeFlag':setNodeFlag, 'node':node, 'port':port, 'lines':lines, 'bSampleNotExist':bSampleNotExist})
File "D:\Python25\Lib\site-packages\django\shortcuts\__init__.py" in render_to_response
  20.     return HttpResponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs)
File "D:\Python25\Lib\site-packages\django\template\loader.py" in render_to_string
  181.         t = get_template(template_name)
File "D:\Python25\Lib\site-packages\django\template\loader.py" in get_template
  157.     template, origin = find_template(template_name)
File "D:\Python25\Lib\site-packages\django\template\loader.py" in find_template
  134.             source, display_name = loader(name, dirs)
File "D:\Python25\Lib\site-packages\django\template\loader.py" in __call__
  42.         return self.load_template(template_name, template_dirs)
File "D:\Python25\Lib\site-packages\django\template\loader.py" in load_template
  45.         source, display_name = self.load_template_source(template_name, template_dirs)
File "D:\Python25\Lib\site-packages\django\template\loaders\filesystem.py" in load_template_source
  39.                     return (file.read().decode(settings.FILE_CHARSET), filepath)
File "D:\Python25\lib\encodings\utf_8.py" in decode
  16.     return codecs.utf_8_decode(input, errors, True)

Exception Type: UnicodeDecodeError at /supe/resolveTask/newSample/1,/
Exception Value: 'utf8' codec can't decode byte 0xa4 in position 945: unexpected code byte
哪位帮忙看一下   这个问题困扰好几天了    再搞不定就会出问题了   望各位多帮忙

作者: jizhanlong   发布时间: 2011-06-14

还是字符编码的问题。

你先用type(variale)看一下变量的类型,是unicode还是str.
最好帖些代码上来

作者: iamacnhero   发布时间: 2011-06-14

File "D:\Python25\Lib\site-packages\django\template\loaders\filesystem.py" in load_template_source
  39.                     return (file.read().decode(settings.FILE_CHARSET), filepath)
File "D:\Python25\lib\encodings\utf_8.py" in decode
  16.     return codecs.utf_8_decode(input, errors, True)

栈回退显示编码问题

0xa4 不是有效的utf-8字符,确定你的文档是按照utf-8编码或者兼容编码保存,否则就要转换。
话说你在做繁体开发?

作者: ccporxy   发布时间: 2011-06-14