s = '0123456789'
nchars = len(s)
# string to int or long. Type depends on nchars
x = sum(ord(s[byte])<<8*(nchars-byte-1) for byte in range(nchars))
# int or long to string
''.join(chr((x>>8*(nchars-byte-1))&0xFF) for byte in range(nchars))
产生
'0123456789'
和
x = 227581098929683594426425L
票数 14
EN
Stack Overflow用户
发布于
2010-09-09 11:53:18
对网址进行编码的BASE58呢?比如flickr就是这样。
# note the missing lowercase L and the zero etc.
BASE58 = '123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ'
url = ''