python 提取dict的key和value

自己封装的方法:两个变量接收返回的key,value

def dict_key_value(data):
    k=str(data.keys()).replace("dict_keys","").replace("(","").replace(")","").replace("[","").replace("]","").replace("'",'')
    v=str(data.values()).replace("dict_values","").replace("(","").replace(")","").replace("[","").replace("]","").replace("'",'')
    return k,v

if __name__ == '__main__':
    data = {
        'HJB779158HJB': 'MyTalkingTom-meizujinke-jinkead-rc-b585-v4.8.0.585.apk'}
    key,value=dict_key_value(data)
    print("key:",key)
    print("value:",value)

猜你喜欢

转载自blog.csdn.net/liming066/article/details/82178602