python转换excel列号为数字数字转为列号
def convert_to_number(letter, columnA=0):
"""
字母列号转数字
superme怎么读法律英语翻译columnA: 你希望A列是第⼏列(0 or 1)? 默认0
return: int
"""
ab ='_ABCDEFGHIJKLMNOPQRSTUVWXYZ'
letter0 = letter.upper()twice是什么意思
w =0
for _ in letter0:
w *=26
w += ab.find(_)
教育部留学服务中心电话
return w -1+ columnA
def convert_to_letter(number, columnA=0):
"""
英语电话用语数字转字母列号
大筋columnA: 你希望A列是第⼏列(0 or 1)? 默认0
return: str in upper ca
"""
ab ='_ABCDEFGHIJKLMNOPQRSTUVWXYZ'
n = number - columnA
x = n %26
if n >=26:
n =int(n /26)
return convert_to_letter(n,1)+ ab[x +1]
el:
return ab[x +1]
二人世界 英文
name = convert_to_number('EL')
print(name)
⼗六进制⼗进制相互转换,不适合excel
ALPHABET =('a','b','c','d','e','f','g','h','i','j','k','l','m',
'n','o','p','q','r','s','t','u','v','w','x','y','z')
paul
def alphabet2digit(alphabet):
"""26进制 -> 10进制"""
return sum(ALPHABET.index(a)*(26** e)for e, a in enumerate(reverd(alphabet)))新概念英语第一册视频下载
it是什么def digit2alphabet(digit):
"""10进制 -> 26进制"""
mod, remainder =divmod(digit,26)
alphabet = ALPHABET[remainder]
while mod:
mod, remainder =divmod(mod,26)
alphabet = ALPHABET[remainder]+ alphabet
return alphabet