我正在使用Python 3,並且在運行此文件時有一點問題。ValueError當我在Python中運行文件
txt = input("Which file do you want to use?")
file = codecs.open(txt,"r","utf-8")
player=[]
name=None
longest_cast=0
result=[]
for line in file:
row=line.split()
row_1=len(row[1])
row_2=len(row[2])
if len(row)<5:
mu=float(row[1])
sigma=float(row[2])
for r in range(0,6):
cast=random.normalvariate(mu,sigma)
result.append(cast)
if max(result)>longest_cast:
longest_cast=max(result)
name=row[0]
print("The winner is", name, "who got", longest_cast, "meters. Congrats! :)")
我得到這個錯誤代碼。
ValueError: max() arg is an empty sequence
我該怎麼辦?有什麼建議麼?
看起來結果等於[]和max([])拋出ValueError異常 –
你真的需要在這裏修正你的縮進,python是空白敏感的,所以這裏的縮進可能會導致你的問題。 – shuttle87
如果您的問題已解決,請刪除您的問題(如有可能),或接受(或發佈)答案。刪除您的問題內容對任何人都沒有幫助。 – deceze