Python---字符串的移位

将字符串转换为列表然后进行移位:

demo:

result="f72c5a36569418a20907b55be5bf95ad"
relist=list(result)
i=0
while i<16:
    new_char=relist[i]
    relist[i]=relist[i+16]
    relist[i+16]=new_char
    i=i+1
    
result = "".join(relist)
print(result)

relist=list(result)


zhongjian=relist[0]
relist[0]=relist[1]
relist[1]=zhongjian

if len(relist)>=3:
    two=2
    while two<len(relist):
        aaaa=relist[two]
        relist[two]=relist[two+1]
        relist[two+1]=aaaa
        two=two+2
        

result = "".join(relist)
print(result)

你可能感兴趣的:(Python)