python中,unicode对象怎么转换成dict?

result = {"count":4,"sub_images":[{"url":"http://p3.pstatp.com/origin/5e8800034ace2b572928","width":690,"url_list":[{"url":"http://p3.pstatp.com/origin/5e8800034ace2b572928"},{"url":"http://pb9.pstatp.com/origin/5e8800034ace2b572928"},{"url":"http://pb1.pstatp.com/origin/5e8800034ace2b572928"}],"uri":"origin/5e8800034ace2b572928","height":1003},{"url":"http://p1.pstatp.com/origin/6158000163084595c6fb","width":690,"url_list":[{"url":"http://p1.pstatp.com/origin/6158000163084595c6fb"},{"url":"http://pb3.pstatp.com/origin/6158000163084595c6fb"},{"url":"http://pb9.pstatp.com/origin/6158000163084595c6fb"}],"uri":"origin/6158000163084595c6fb","height":975},{"url":"http://p3.pstatp.com/origin/5e820003c5d5ac717d18","width":690,"url_list":[{"url":"http://p3.pstatp.com/origin/5e820003c5d5ac717d18"},{"url":"http://pb9.pstatp.com/origin/5e820003c5d5ac717d18"},{"url":"http://pb1.pstatp.com/origin/5e820003c5d5ac717d18"}],"uri":"origin/5e820003c5d5ac717d18","height":1035},{"url":"http://p3.pstatp.com/origin/6158000163329ce51ec3","width":690,"url_list":[{"url":"http://p3.pstatp.com/origin/6158000163329ce51ec3"},{"url":"http://pb9.pstatp.com/origin/6158000163329ce51ec3"},{"url":"http://pb1.pstatp.com/origin/6158000163329ce51ec3"}],"uri":"origin/6158000163329ce51ec3","height":1035}],"max_img_width":690,"labels":["u738bu5b50u6587","Burberry","u65f6u88c5u642du914d"],"sub_abstracts":["u738bu5b50u6587u66ddu5149u6700u65b0u673au573au8857u62cduff0cu6df1u84ddu8272Burberryu5916u5957u642du914dStuart Weitzmanu9ed1u8272u957fu9774uff0cu7b80u6d01u5e05u6c14u3002u8fd9u4e48u4e45u7684u745cu4f3du679cu7136u4e0du662fu767du7ec3u7684uff0cu201cu66f2u5996u7cbeu201du9a7eu9a6du670du88c5u7684u80fdu529bu597du50cfu8d8au6765u8d8au5f3au4e86u3002"," "," "," "],"sub_titles":["u738bu5b50u6587u66ddu5149u6700u65b0u673au573au8857u62cduff0cu6df1u84ddu8272u5916u5957u642du914du9ed1u8272u957fu9774","u738bu5b50u6587u66ddu5149u6700u65b0u673au573au8857u62cduff0cu6df1u84ddu8272u5916u5957u642du914du9ed1u8272u957fu9774","u738bu5b50u6587u66ddu5149u6700u65b0u673au573au8857u62cduff0cu6df1u84ddu8272u5916u5957u642du914du9ed1u8272u957fu9774","u738bu5b50u6587u66ddu5149u6700u65b0u673au573au8857u62cduff0cu6df1u84ddu8272u5916u5957u642du914du9ed1u8272u957fu9774"]}


以上result,是我在网页中获取到的,但是print type(result)显示该对象为unicode,不是dict

请问怎么样能转换成dict?

LNYIE
浏览 7719回答 2
2回答

慕码人5092043

result = result.encode('utf-8')  #将unicode转换成stringjd = json.loads(result)   #将string转换成dict[如有雷同,纯属抄袭]

LNYIE

自问自答,result = result.encode('utf-8')  #将unicode转换成stringjd = json.loads(result)   #将string转换成dict
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python