Created
October 20, 2017 05:13
-
-
Save righ/559b7710af88065085fe54211c239552 to your computer and use it in GitHub Desktop.
Excelの列名変換
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from string import ascii_uppercase | |
def to_column(number): | |
""" | |
:param int number: 1以上の数値 | |
""" | |
string = '' | |
while True: | |
number -= 1 | |
string = ascii_uppercase[number % 26] + string | |
number //= 26 | |
if not number: | |
return string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment