给你一个字符串columnTitle,表示Excel 表格中的列名称,返回该列名称对应的序列号。
- 代码如下:
class Solution:
def titletoNumber(self, columnTile):
words = {chr(i + 65): i+1 for i in range(26)}
res = 0
length = len(columnTile)
for i in range(length):
res += words[columnTile[i]] * 26 ** (length - 1 - i)
return res



