简体   繁体   中英

my code is throwing a indent error and i cant find the problem

i am using the pyqt5 module and its throwing a indent error here is the bit of code that's throwing the error

i have tried to place the block after the text browser variable

from PyQt5 import QtCore, QtGui, QtWidgets

 with open("data.txt", "a+") as data_file:
 try:
     for text in data_file:
         textBrowser.append(text)
 else:
     for texts in data_file:
         textBrowser.append(texts)`

I'm not sure about your indentation but the correct form of try-else IMO is try-except-else. Like this:

try:
    ...
except Exception:
    ...
else:
    ...

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM