我有下面的代碼來做一些ocr的東西。當這完成後,我想生成一些窗口。但是,每當我運行我的代碼,我得到了第13行的以下錯誤:unindent does not match any outer indentation level
我認爲這很奇怪,因爲我沒有看到我的代碼中有任何奇怪的縮進。見下面我的代碼:tkinter上的python縮進錯誤
import Tkinter as tk
from os import *
from PIL import Image
from tesserocr import PyTessBaseAPI, RIL
root = tk.Tk()
tk.Label(root, text="this is the root window").pack()
root.geometry("200x20")
def window(x, y, w, h):
display = tk.Toplevel()
線下生成錯誤:
display.geometry('%dx%d+%d+%d' % (w, h, x, y))
tk.Label(display, text="sensitive info").pack()
def main():
path = "~/Desktop/media_argeology/Check_sensitive/"
system("mkdir -p {0}".format(path))
system("screencapture {0}temp.png".format(path))
system('sips -Z 4000 temp.png')
image = Image.open('temp.png')
with PyTessBaseAPI() as api:
api.SetImage(image)
boxes = api.GetComponentImages(RIL.TEXTLINE, True)
for i, (im, box, _, _) in enumerate(boxes):
window(box['x'], box['y'], box['w'], box['h'])
print "exit first function"
main()
root.mainloop()
我是很新的蟒蛇,但我有其他語言的一些編程經驗。任何幫助是極大的讚賞!
你可能有標籤和空格的代碼中的組合。這是我最好的猜測 – SarathSprakash
沒問題給它一張支票 – FutureCake
你甚至可以在問題的源頭看到它。 'display = ...'這一行用一個製表符縮進,下面一行用四個空格。 –