You can split the string into a list of substrings:
>>> s="xxxxxxxx,yyyyyyyyyyyy,zzzzzzzzz"
>>> parts = s.split(',')
>>> parts
['xxxxxxxx', 'yyyyyyyyyyyy', 'zzzzzzzzz']
Then you can re-order:
>>> reordered = parts[0] + parts[2] + parts[1]
>>> reordered
['xxxxxxxx', 'zzzzzzzzz', 'yyyyyyyyyyyy']
And rejoin:
>>> ','.join(reordered)
'xxxxxxxx,zzzzzzzzz,yyyyyyyyyyyy'
1
solved How can i change the position of substring within a string in Python?