leetcode Excel Sheet Column Number python

Excel Sheet Column Number

Related to question Excel Sheet Column Title

Given a column title as appear in an Excel sheet, return its corresponding column number.

For example:

    A -> 1
    B -> 2
    C -> 3
    ...
    Z -> 26
    AA -> 27
    AB -> 28 
python code

class Solution:
# @param {string} s
# @return {integer}
def titleToNumber(self,s):
  ss=list(s)
  summ=0
  while len(ss)>=1:
    num=(ord(ss[0])-64)    #26进制
    summ=summ*26+num
    ss.pop(0)
  return summ

posted @ 2015-06-14 07:14  轻抚离殇  阅读(149)  评论(0编辑  收藏  举报