程序不会发布错误消息。它在python 2中运行良好,当我尝试转换它时,它将无法工作。
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