2 Star 1 Fork 1

夏天 / 网址缩短-短网址

Create your Gitee Account
Explore and code with more than 6 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Without author's permission, this code is only for learning and cannot be used for other purposes.
Clone or download
py_10_to_62.py 919 Bytes
Copy Edit Web IDE Raw Blame History
夏天 authored 2019-07-10 18:42 . 提交10进制转62进制的方法
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
__author__ = 'xiajing'
baseList = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def changeBase(n,b):
x,y = divmod(n,b)
if x>0:
return changeBase(x,b) + baseList[y]
else:
return baseList[y]
def changeToTenBase(s,b):
sL = list(s)
sL.reverse()
result = 0
for x in range(len(sL)):
result = result + baseList.index(sL[x])*(b**x)
return result
def is_polydivisible(s, b):
for x in range(len(s)):
if changeToTenBase(s[:x+1],b)%(x+1) != 0:
return False
return True
def get_polydivisible(n, b):
count = 0
result = 0
while count < n:
baseResult = changeBase(result,b)
if is_polydivisible(baseResult,b):
count = count + 1
result = result + 1
return baseResult
if __name__ == '__main__':
print(changeBase(62,62))

Comment ( 0 )

Sign in for post a comment

Python
1
https://gitee.com/Xiajing869/test_dwz.git
git@gitee.com:Xiajing869/test_dwz.git
Xiajing869
test_dwz
网址缩短-短网址
master

Search

101046 36f486cf 1899542 101055 4cb66026 1899542