![](/img/trans.png)
[英]IndentationError: unexpected indent while web scraping using Selenium and Python
[英]IndentationError: unexpected indent while using opencv (in Atom and comipiling in Macbook zsh Terminal)
File "background.py", line 1
import cv2
^
IndentationError: unexpected indent
我收到這個錯誤。 我再次通過終端卸載並重新安裝了 opencv。 檢查import cv2
是否在 Jupyter Notebook 中工作並且確實有效。 誰能幫幫我嗎?
import cv2
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret,back = cap.read()
if ret:
cv2.imshow("image",back)
if cv2.waitkey(5) == ord('q'):
cv2.imwrite('image.jpg',back)
break
cap.release()
cv2.destroyAllWindows()
您的整個腳本縮進 1 個空格。 waitkey 中的“K”也應該是大寫字母。
import cv2
cap = cv2.VideoCapture(0)
while cap.isOpened():
ret,back = cap.read()
if ret:
cv2.imshow("image",back)
if cv2.waitKey(5) == ord('q'):
cv2.imwrite('image.jpg',back)
break
cap.release()
cv2.destroyAllWindows()
嘗試這個。
從 cap = cv2.VideoCapture(0) 中刪除空間
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.