Created
April 2, 2020 04:56
-
-
Save AntiKnot/267a09407cc8a447c736962160a1e136 to your computer and use it in GitHub Desktop.
十进制转任意进制
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| code = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 'a', 'b', 'c', 'd'] | |
| # todo unicode 可以简化这个书写 62个[0-9,a-z,A-Z] 乱序可以制作一个混淆 算是加密算法 | |
| def ten2n(x, n): | |
| b = [] | |
| while True: | |
| j = x // n | |
| k = x % n | |
| b += [k] | |
| if j == 0: | |
| break | |
| x = j | |
| b.reverse() | |
| res = [code[item] for item in b] | |
| return res | |
| if __name__ == '__main__': | |
| print(ten2n(12311662, 13)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment