【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')

上一篇:005.Getting started with ASP.NET Core MVC and Visual Studio -- 【VS开发asp.net core mvc 入门】


下一篇:【LeetCode】168 & 171- Excel Sheet Column Title & Excel Sheet Column Number