Python 3.x 韩元';t打印错误消息。它在Python2中工作得很好,但当我尝试将其更改为Python3时,它就不起作用了

Python 3.x 韩元';t打印错误消息。它在Python2中工作得很好,但当我尝试将其更改为Python3时,它就不起作用了,python-3.x,python-2.x,Python 3.x,Python 2.x,程序不会发布错误消息。它在Python2中工作得很好,当我尝试转换它时,它不会工作 def getData(filename): """Create Database with raw text as the entries. """ with open(filename, 'r') as f reader = csv.reader(f, dialect='excel-tab') dat = [] for row in

程序不会发布错误消息。它在Python2中工作得很好,当我尝试转换它时,它不会工作

def getData(filename):
    """Create Database with raw text as the entries.
    """
    with open(filename, 'r') as f
        reader = csv.reader(f, dialect='excel-tab')  
        dat = []
        for row in reader:
            if len(row) != 4: 
               sys.exit("\nInput read error!\nData file incomplete!\n")
            if '' in row:
               sys.exit("\nInput read error!\nEmpty field found!\n")
            dat.append(row)
        dat = dat[1:]                                                   
        return dat

它怎么不起作用?(顺便问一下,错误消息中的感叹号通常不是一个好主意。)这是您的全部代码吗?在哪里定义了
系统
?无法复制。使用Python3和常用的
sys
模块,
exit
在退出之前打印给定的消息。你确定这些行已经执行了吗?也许程序以其他方式退出?向我们展示你的全部代码。我可以看到函数没有任何问题。请提供一份能证明您的问题的报告。