data_dict={ "k1":"v1", "k2":"v2", "k3":"v3", "k4":"v4", } #类型1: rel={} print(bool(rel)) #False for k,v in data_dict.items(): temp_dict={} temp_dict[k]=v if temp_dict: rel[temp_dict[k]]=temp_dict print(rel) ''' {'v1': {'k1': 'v1'}, 'v2': {'k2': 'v2'}, 'v3': {'k3': 'v3'}, 'v4': {'k4': 'v4'}} '''