-2
我得到一個意外的unindent這個函數,我仍然收到錯誤,即使代碼正確縮進。我試圖用一個不同之處,並多次和我仍然得到錯誤:意外unindent函數
def showHand():
print('This game will let you open your saved Dream Hand.')
#getting the file name the user wants to open
filename = input('Please enter your dream hand file name: ')
try:
#opening
infile = open(filename, 'r')
#reading the values inline
card1 = int(infile.readline())
card2 = int(infile.readline())
card3 = int(infile.readline())
card4 = int(infile.readline())
card5 = int(infile.readline())
#closing file
infile.close()
#printing values through face value
print('Your Dream Hand is: ')
faceValue(card1)
faceValue(card2)
faceValue(card3)
faceValue(card4)
faceValue(card5)
except IOError:
print('An error has occurred')
finally:
print('Thank you for playing')
你指的是什麼縮進?你的代碼?你的輸出?請編輯您的問題,以便更清楚。並顯示你的程序輸出來說明問題。此外,您的標題提到了一個意想不到的「unindent」,但是您的描述中提到了意想不到的「縮進」。 *注:我刪除了提及搜索其他問題;不相關。另外請注意:我必須重新格式化您的代碼,因爲您的註釋是左對齊的,並被解釋爲段落標題。* –
當我嘗試運行完整程序時,我收到了一個意想不到的錯誤消息,它指的是第一行def showHand(): –
@DavidMakogon爲什麼用'IndentError'編輯代碼? –