-1
下面的代碼的Python IndentationError此時如果
def properties(imgnum):
...
if imgnum == 6:
bonus = 0
#img6.gif
photo = tkinter.PhotoImage(file = './Images/img6.gif')
root.geometry("450x450")
root.update()
canvas.create_image(225,225, image=photo)
root.mainloop()
props = {...}
if imgnum == 7:
bonus = 0
#img7.gif
photo = tkinter.PhotoImage(file = './Images/img7.gif')
root.geometry("450x450")
root.update()
canvas.create_image(225,225, image=photo)
root.mainloop()
props = {}
if imgnum == 8:
bonus = 0
#img8.gif
photo = tkinter.PhotoImage(file = './Images/img8.gif')
root.geometry("450x450")
root.update()
canvas.create_image(225,225, image=photo)
root.mainloop()
props = {}
和這裏的錯誤:
Traceback (most recent call last):
File "C:\Users\[USER]\Desktop\Eoy\EOY.py", line 1, in <module>
from EOY_props import properties
File "C:\Users\[USER]\Desktop\Eoy\EOY_props.py", line 55
if imgnum == 7:
^
IndentationError: expected an indented block
我聽說這是從混合製表符和空格,我沒做什麼。所有的代碼都與其他代碼一樣,所有括號和括號都被關閉。 道具詞典在待辦事項列表中,這是一項正在進行的工作。
它可能是與未檢測的聲明下的任何文件你的'if'語句和你的方法聲明之間的代碼。你可以發佈該代碼嗎? – Bryan
上面的代碼是什麼'if imgnum == 7:'看起來像什麼?這個錯誤通常意味着'if imgnum ...'的縮進級別根據之前的內容而不正確。在這種情況下,它看起來像是期待'if imgnum == 7'根據上一行縮進更多。 – dano
還有更多道具{...}比這裏給出的更多。嘗試用'props = {}'替換它,看看你是否有同樣的問題。在if作爲sentinals之前立即在道具和縮進語句之後添加縮進語句。 – tdelaney