Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
如果我的 Excel 表格如上图所示
那么如何获取 MT 列的列号?
for mt in sheet.row_values(0): print mt if mt=='MT': break
有没有像 sheet.row_values(0).colnumber 这样的函数?
col_idx = -1 for idx, mt in enumerate(sheet.row_values(0)): print mt if mt=='MT': col_idx = idx break
RickyA's 也可以拼写
next(i for i, mt in enumerate(sheet.row_values(0)) if mt=='MT')
next如果需要,可以给定一个默认值。
next