171 excel sheet column number
171. Excel Sheet Column Number
题目:
https://leetcode.com/problems/excel-sheet-column-number/
难度:
Easy
26进制的反击
class Solution(object):
def titleToNumber(self, s):
"""
:type s: str
:rtype: int
"""
maps = {}
for i in range(65,91):
maps[chr(i)] = i - 64
lst = list(s)
lst.reverse()
num = 0
for idx,item in enumerate(lst):
num += maps[item] * (26 ** idx)
return num