@@ -0,0 +1,806 @@
+# -*- coding:utf-8 -*-%0A%0A%22%22%22%0Aconvert dict%0A%7Bu'detail.province': u'www11', u'mobile': u'4561', u'detail.city': u'qqq11', u'email': u'1231'%7D%0A%0Ato%0A%0A%7Bu'mobile': u'4561', u'detail': %7Bu'province': u'www11', u'city': %7Bu'number': u'qqq11'%7D%7D, u'email': u'1231'%7D%0A%0A%22%22%22%0A%0A%0Adef convert(doc):%0A    new_doc = %7B%7D%0A    for field in doc:%0A        dots = field.split('.')%0A        curr_doc = doc%5Bfield%5D%0A        if len(dots) == 1:%0A            new_doc%5Bfield%5D = curr_doc%0A        else:%0A            edit_doc = new_doc%0A            for part in dots%5B:-1%5D:%0A                edit_doc = edit_doc.setdefault(part, %7B%7D)%0A            edit_doc%5Bdots%5B-1%5D%5D = curr_doc%0A%0A    return new_doc%0A%0A%0Aif __name__ == '__main__':%0A    src = %7Bu'detail.province': u'www11', u'mobile': u'4561', u'detail.city.number': u'qqq11', u'email': u'1231'%7D%0A    print(convert(src))%0A

add dict convert snippets