171. Excel Sheet Column Number (Easy)
生活随笔
收集整理的這篇文章主要介紹了
171. Excel Sheet Column Number (Easy)
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
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
轉載于:https://www.cnblogs.com/yancea/p/7504381.html
總結
以上是生活随笔為你收集整理的171. Excel Sheet Column Number (Easy)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: PB实用技巧
- 下一篇: UEditor编辑器第一次赋值失败的解决