Given a column title as appear in an Excel sheet, return its corresponding column number.
For example:
A -> 1B -> 2C -> 3...Z -> 26AA -> 27AB -> 28
思路:
1.26进制转化为十进制,ord()函数;
2.逐个读入字符串中的每个字符进行处理转换;
class Solution():def titleToNumber(self, s):""":type s: str:rtype: int"""num = 0 for e in s:num = num * 26 + ord(e) - ord('A') + 1return num
相关问题:http://www.cnblogs.com/yancea/p/7506456.html