我是Python& xlrd和我在执行(看似)简单的字符串比较时遇到了问题:
import xlrd
workbook = xlrd.open_workbook('/home/Y725271/Desktop/test_report.xls')
sheet = workbook.sheet_by_index(0)
# Iterate all of the column names and see if col apple exists
col_len = sheet.row_len(0)
for i in range(col_len):
col = sheet.cell_value(0,i)
if col.lower() == "apple"
print "match"
else
print "mismatch"
当我通过解释器运行代码时,出现以下错误:
File "<stdin>", line 3
if col.lower() == "apple"
^
SyntaxError: invalid syntax
我错过了什么或做错了什么?我正在比较两个字符串,对吧?