python json_encode


import json

json_encode = json.dumps
json_decode = json.loads

a = '{"a":123}'
b = json_decode(a)
c = json_encode(b)
print 'original:'+a+'\n'
print 'decoded:' + str(b) + '\n'
print 'encoded' + c + '\n'

for python >= 2.6


implode and explode
实现explode
>>> str = 'a|b|c|d|e'
>>> str.split("|")
['a', 'b', 'c', 'd', 'e']
 
实现implode
>>> list = ['a', 'b', 'c', 'd', 'e']
>>> "|".join(list)
'a|b|c|d|e'

你可能感兴趣的:(python)