首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >快速排序算法UnicodeDecodeError

快速排序算法UnicodeDecodeError
EN

Stack Overflow用户
提问于 2014-01-10 23:51:11
回答 1查看 95关注 0票数 0

错误: builtins.UnicodeDecodeError:'utf-8‘编解码器无法解码位置448中的字节0xa1 :开始字节无效

代码语言:javascript
复制
def quicksort(Info):
        lesser=[]
        greater=[]
        if len(Info) <= 1:
                return Info
        for swap in Info[1:]:
                if swap < Info[0]:
                        lesser.append(swap)
                else:
                        greater.append(swap)
        print(quicksort(lesser)+Info[0:1]+quicksort(greater))   

a= ['Babado Novo: Ver-te Mar', 'Natas es Satan', 'All Out War', '"The Cell"', '¡Ja me maaten...!', '"Formula 1: BBC Sport"', 'Ambos mundos', 'Angels with Dirty Faces', 'Barrio Gangsters', 'The LXD: The Secrets of the Ra', '90 Jahre Burgenland', 'La guitarra muda', 'Alma gitana', 'Depravada', 'Especial humor: Vaya... y vuelta', 'Entre las patas de los caballos', 'Fillet of Soul', 'Llamada', 'All of Her', "Hustler's Untrue Hollywood Stories: Angelina vs. Jennifer", 'Black Tranny Whackers 12', '"Davno ne videlis"', 'Anna II', '"The American Experience"', 'Meus Prêmios Nick 2012', 'Possessed', 'Holzapfel weiß alles', 'Lightspeed University: Cheerleader Power', 'Kid Millions', 'Monster High', '"Big Brother\'s Bit on the Side"', '"Britain\'s Got Talent"', "Heut' kommt's drauf an", "Buffalo Jill's on DVD 2004: Swimsuit Edition", '"Sigue, sigue Plàstic"', '"Move Like Michael Jackson"']

quicksort(a)
EN

回答 1

Stack Overflow用户

发布于 2014-01-10 23:59:46

首先,将#coding=utf8添加到脚本文件的顶部。

其次,将你的文件保存为utf-8,默认情况下可能是ANSI。

然后我会在运行你的代码时出错:

代码语言:javascript
复制
['"Big Brother\'s Bit on the Side"', '"Britain\'s Got Talent"']
Traceback (most recent call last):
  File "D:\Documents\Desktop\a.py", line 23, in <module>
    quicksort(a)
  File "D:\Documents\Desktop\a.py", line 19, in quicksort
    print(quicksort(lesser)+Info[0:1]+quicksort(greater))
  File "D:\Documents\Desktop\a.py", line 19, in quicksort
    print(quicksort(lesser)+Info[0:1]+quicksort(greater))
  File "D:\Documents\Desktop\a.py", line 19, in quicksort
    print(quicksort(lesser)+Info[0:1]+quicksort(greater))
  File "D:\Documents\Desktop\a.py", line 19, in quicksort
    print(quicksort(lesser)+Info[0:1]+quicksort(greater))
  File "D:\Documents\Desktop\a.py", line 19, in quicksort
    print(quicksort(lesser)+Info[0:1]+quicksort(greater))
TypeError: unsupported operand type(s) for +: 'NoneType' and 'list'
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21048608

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档