[英]Convert string to dictionary where keys are not strings
我解析HTML文件的我最終的東西, 幾乎看起來像一條巨蟒字典...除了鍵不是字符串。 因此我不能使用ast.literal_eval()
或json.loads()
。
字符串看起來像這樣:
x = '{name:'Berlin, Germany', daypart:'night', href:'/en/de/berlin/10178/weather-forecast/178087', icon:'http://vortex.accuweather.com/adc2010/images/icons-numbered/33-m.png', bg:'cl', temp:'22', realfeel:'22', text:'Clear'}'
我想將其轉換為python字典,其中鍵也是字符串。 我認為這需要一些好的'正則表達式,但我不知道該怎么做。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.