このコードは、私がこのコードで何を間違って行ったのか分かりません。 Python 2.7を使用してtkinter内でバイナリ検索を実行しようとしているとき。プログラムがうまくいきません。これは、私はエラーがあるtkinter gui python 2.7のバイナリ検索でエラーが発生する012
http://www.pythonschool.net/data-structures-algorithms/binary-search/
に私のプログラムをベースとしたコードです:Tkinterのコールバックトレースバック(最新の呼び出しの最後)での例外:「Cファイル:を\ Python27 \ libに\ libに-TKの\ののTkinter。コール・リターンself.funcでPY」、ライン1536、(*引数)例外TypeError:binarySearch()は正確に2つの引数(0が与えられた)すべての
from Tkinter import *
import csv
with open('scoresRecord.csv', 'rb') as f:
reader = csv.reader(f)
your_list = list(reader)
root = Tk()
root.resizable(0,0)
root.title("Score Board")
def binarySearch(myitem,myList):
found = False
bottom = 0
top = len(myList)-1
while bottom<=top and not found:
middle = (bottom+top)//2
if myList[middle]== myitem:
found = True
elif myList[middle] < myitem:
bottom = middle + 1
else:
top = middle-1
return found
if __name__=="__main__":
Scorelist = [row[0] for row in your_list]
Dismissallist =[row[1] for row in your_list] # create a list of only the dismissal
Venuelist =[row[2] for row in your_list] # create a list of only the venue
item = int(input(entScore.get()))
Scorelist = map(int, Scorelist)
rowPos = Scorelist.index(item)
isitFound = binarySearch(item,Scorelist)
if isitFound:
Score= Scorelist[rowPos]
Dismissal= Dismissallist[rowPos]
Venue= Venuelist[rowPos]
else:
Score= ("Not Found")
Dismissal= ("Not Found")
Venue= ("Not Found")
numScoreLbl.configure(text=Score)
numDismissal.configure(text=Dismissal)
outVenue.configure(text=Venue)
#==========GUI Section==================#
あなたが実行しているコードと実際に一致するようにインデントを修正するのがよいでしょう。インデントはPythonでは非常に重要です。投稿した内容はまったく動かないでしょう。 –