Q: 如何将字符串N个一组地反序,比如将'0123456789'反序成'8967452301'?字符串长 度不限,可能包含各种字符,不限于数字。 A: bluerust 2016-07-19 1) x = '0123456789' n = 2 ''.join([x[i:i+n] for i in xrange(0,len(x),n)][::-1]) ''.join(reversed([x[i:i+n] for i in xrange(0,len(x),n)])) 2) import re x = '0123456789' ''.join(re.findall('..',x)[::-1]) 3) x = '0123456789' n = 2 ''.join(map(''.join, zip(*[iter(x)]*n))[::-1]) 4) x = '0123456789' ''.join(map(str.__add__, x[-2::-2], x[-1::-2]))