我有一个字符串:
datalist = "popupWin:'http://www.adachikan.net/index.php/catalog/product/gallery/id/3049/image/1861/', useZoom: 'cloudZoom', smallImage: 'http://www.adachikan.net/media/catalog/product/cache/1/image/315x400/9df78eab33525d08d6e5fb8d27136e95/1/8/187267-875-40.jpg'"
我想将此字符串转换为 Python 字典。我可以使用 split 来打破字符串和表单列表:
datalist.split(',') = ["popupWin:'http://www.adachikan.net/index.php/catalog/product/gallery/id/3049/image/1861/'",
" useZoom: 'cloudZoom'",
" smallImage: 'http://www.adachikan.net/media/catalog/product/cache/1/image/315x400/9df78eab33525d08d6e5fb8d27136e95/1/8/187267-875-40.jpg'"]
依此类推,以获得想要的结果......
我有任何简单的方法可以将其datalist
用作字典,例如:datalist['smallImage']
等。