#-*- 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')
相关文章
- 01-08[Algorithm] 171. Excel Sheet Column Number
- 01-08【easy】168. Excel Sheet Column Title 171. Excel Sheet Column Number
- 01-08171. Excel Sheet Column Number(C++)
- 01-08LeetCode: 171 Excel Sheet Column Number(easy)
- 01-08LeetCode 171 Excel Sheet Column Number
- 01-08【leetcode❤python】171. Excel Sheet Column Number
- 01-08【一天一道LeetCode】#171. Excel Sheet Column Number
- 01-08【LeetCode】168. Excel Sheet Column Title
- 01-08Leetcode No.168 Excel Sheet Column Title Excel表列名称(c++实现)
- 01-08LeetCode 每日一题 168. Excel Sheet Column Title(数学)