-1
我有一個字符串,我想變成字典。將字符串轉換爲字典python
我的字符串:
minmax = "min: " + min(allvalueslist) + ", " + "max: " + max(allvalueslist)
輸出:
min: 29.47, max: 35.96
我想到的是,下面的代碼會工作,但它失敗:
minmax = dict("min: " + min(allvalueslist) + ", " + "max: " + max(allvalueslist))
錯誤:
ValueError: dictionary update sequence element #0 has bad length; 2 is required
Errr:'極大極小= { '分鐘':分鐘(your_list) ,'max':max(your_list)}'? –
試試'minmax = dict(min = min(allvalueslist),max = max(allvalueslist))' –
試圖通過字符串傳遞的任何原因?爲什麼不做minmax = dict(min = min(allvalueslist),max = max(allvalueslist))? –