Python - bytes reversed ABCDEF -> EFCDAB
#!/usr/bin/python
#-*- coding:utf-8 -*-
'''
@author: Duncan
'''
# option1
Byte = 'ABCDEF'
print "".join(reversed([Byte[i:i+2] for i in range(0,
len(Byte), 2)]))
# option2
temp_list = []
for i in range(0, len(Byte), 2):
temp_list.append(Byte[i:i+2])
print "".join(reversed(temp_list))
|
留言
張貼留言