请教:python replace产生乱码问题
>>> result =u'''fjadkjadfadfjñfjkadfjsdkj''' >>> result=result.replace('ñ',chr(241)) >>> print result fjadkjadfadfj駀jkadfjsdkj
我预期的输出结果是:
chr(241) 是
[ 本帖最后由 redice 于 2010-11-23 17:12 编辑 ]
>>> result =u'''fjadkjadfadfjñfjkadfjsdkj''' >>> result=result.replace('ñ',chr(241)) >>> print result fjadkjadfadfj駀jkadfjsdkj
#!/usr/bin/python # -*- coding: UTF-8 -*-然后文件一律用utf-8编码保存