gpt4 book ai didi

python - 语法错误 : Non-UTF-8 code starting with '\x91'

转载 作者:行者123 更新时间:2023-12-02 03:11:06 24 4
gpt4 key购买 nike

我正在尝试为一个类编写一个二进制搜索程序,我很确定我的逻辑是正确的,但我不断收到非 UTF-8 错误。我从未见过这个错误,任何帮助/澄清都会很棒!谢谢一堆。

这是代码。

def main():


str names = [‘Ava Fischer’, ‘Bob White’, ‘Chris Rich’, ‘Danielle Porter’, ‘Gordon Pike’, ‘Hannah Beauregard’, ‘Matt Hoyle’, ‘Ross Harrison’, ‘Sasha Ricci’, ‘Xavier Adams’]

binarySearch(names, input(str("Please Enter a Name.")))

print("That name is at position "+position)


def binarySearch(array, searchedValue):

begin = 0
end = len(array) - 1
position = -1
found = False

while !=found & begin<=end:
middle=(begin+end)/2

if array[middle]== searchedValue:
found=True
position = middle
elif array[middle] >value:
end=middle-1
else:
first =middle+1
return position

最佳答案

在代码顶部添加此行。它可能会起作用。

    # coding=utf8

关于python - 语法错误 : Non-UTF-8 code starting with '\x91' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23092176/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com