[原创]生成Excel列名

duweifu posted @ 2011年9月22日 22:13 in Scrawl , 771 阅读
def ExcelColumns(num):
    res = ''
    while num > 0:
        res = chr(ord('A') + ((num-1) % 26)) + res
        num = (num-1) / 26
    return res
    
if __name__ == '__main__':
    all_columns = [ExcelColumns(i) for i in range(1000)]
    print all_columns[1:]

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter