string.letters is changes uppercase position between python version, use string.ascii_uppercase
This commit is contained in:
parent
d2a6511a95
commit
94ca01a041
2 changed files with 7 additions and 7 deletions
10
ox/format.py
10
ox/format.py
|
|
@ -21,7 +21,7 @@ def toAZ(num):
|
|||
'CYWOQVJ'
|
||||
"""
|
||||
if num < 1: raise ValueError, "must supply a positive integer"
|
||||
digits = string.letters[26:]
|
||||
digits = string.ascii_uppercase
|
||||
az = ''
|
||||
while num != 0:
|
||||
num, r = divmod(num, 26)
|
||||
|
|
@ -44,7 +44,7 @@ def fromAZ(num):
|
|||
4461
|
||||
"""
|
||||
num = num.replace('-','')
|
||||
digits = string.letters[26:]
|
||||
digits = string.ascii_uppercase
|
||||
r = 0
|
||||
for exp, char in enumerate(reversed(num)):
|
||||
r = r + (pow(26, exp) * (digits.index(char) + 1))
|
||||
|
|
@ -63,7 +63,7 @@ def to26(q):
|
|||
'BDGKMAP'
|
||||
"""
|
||||
if q < 0: raise ValueError, "must supply a positive integer"
|
||||
base26 = string.letters[26:]
|
||||
base26 = string.ascii_uppercase
|
||||
converted = []
|
||||
while q != 0:
|
||||
q, r = divmod(q, 26)
|
||||
|
|
@ -77,7 +77,7 @@ def from26(q):
|
|||
>>> from26('A')
|
||||
0
|
||||
"""
|
||||
base26 = string.letters[26:]
|
||||
base26 = string.ascii_uppercase
|
||||
q = q.replace('-','')
|
||||
r = 0
|
||||
for i in q:
|
||||
|
|
@ -183,7 +183,7 @@ def from32(q):
|
|||
'Y': 30,
|
||||
'Z': 31,
|
||||
}
|
||||
base32 = ('0123456789' +string.ascii_uppercase)[:32]
|
||||
base32 = ('0123456789' + string.ascii_uppercase)[:32]
|
||||
q = q.replace('-','')
|
||||
q = ''.join([base32[_32map[i.upper()]] for i in q])
|
||||
return int(q, 32)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue