【leetcode❤python】171. Excel Sheet Column Number
#-*- coding: UTF-8 -*-
# ord(c) -> integer
##Return the integer ordinal of a one-character string.
##参数是一个ascii字符,返回值是对应的十进制整数
class Solution(object):
def titleToNumber(self, s):
columns=0
n=len(s)
s=s.upper()[::-1]
for c in range(len(s)):
columns+=(ord(s[c])-64)*pow(26,c)
return columns
sol=Solution()
print sol.titleToNumber('a')