168. Excel表列名称
解法一:观察
class Solution:
def convertToTitle(self, n: int) -> str:
res = ""
while n != 0:
m = n % 26 #取模
if m == 0: #对模结果为0特殊处理
n = n // 26 - 1
res = 'Z' + res
else:
n = n // 26
res = chr(m + 64) + res #用asc码
return res最后更新于