defconvertToTitle(n):"""
:type n: int
:rtype: str
"""
rStr =""while n !=0:
res = n %26if res ==0:
res =26
n -=26
rStr =chr(ord('A')+res-1)+ rStr
n = n//26return rStr
写入Excel时将数字列号转换为字符标签列直接上代码def convertToTitle(n): """ :type n: int :rtype: str """ rStr = "" while n != 0: res = n % 26 if res == 0: res = 26 n -= 26 rStr = chr(ord('A')+res-1) + rStr