我发送 post 参数,如
css=request.POST['q']
css=css.encode('utf-8')
和 css 有类似的内容
{
"container": {
"border-color": "white",
"border-width": "0px",
"height": "419px",
"width": "200px",
"border-style": "solid",
"position": "relative",
"background-color": "white"
},
"elemorder": {
"productcode": {
"font-size": "14px",
"line-height": "18px",
"color": "blue",
"border-width": "0px",
"letter-spacing": "0px",
"text-decoration": "none",
"height": "40px",
"width": "200px",
"border-color": "white",
"font-weight": "normal",
"font-style": "normal",
"position": "absolute",
"overflow": "hidden",
"font-family": "Arial",
"border-style": "solid",
"display": "block",
"background-color": "#3385D6",
"text-align": "center"
},
"name": {
"font-size": "14px",
"line-height": "18px",
"color": "blue",
"border-width": "0px",
"letter-spacing": "0px",
"text-decoration": "none",
"height": "40px",
"width": "200px",
"border-color": "white",
"font-weight": "normal",
"font-style": "normal",
"position": "absolute",
"overflow": "hidden",
"font-family": "Arial",
"border-style": "solid",
"display": "block",
"background-color": "#3385D6",
"text-align": "center"
},
"url": {
"font-size": "14px",
"line-height": "18px",
"color": "blue",
"border-width": "0px",
"letter-spacing": "0px",
"text-decoration": "none",
"height": "40px",
"width": "200px",
"border-color": "white",
"font-weight": "normal",
"font-style": "normal",
"position": "absolute",
"overflow": "hidden",
"font-family": "Arial",
"border-style": "solid",
"display": "block",
"background-color": "#3385D6",
"text-align": "center"
},
"price": {
"font-size": "14px",
"line-height": "18px",
"color": "blue",
"border-width": "0px",
"letter-spacing": "0px",
"text-decoration": "none",
"height": "40px",
"width": "200px",
"border-color": "white",
"font-weight": "normal",
"font-style": "normal",
"position": "absolute",
"overflow": "hidden",
"font-family": "Arial",
"border-style": "solid",
"display": "block",
"background-color": "#3385D6",
"text-align": "center"
},
"id": {
"font-size": "14px",
"line-height": "18px",
"color": "blue",
"border-width": "0px",
"letter-spacing": "0px",
"text-decoration": "none",
"height": "40px",
"width": "200px",
"border-color": "white",
"font-weight": "normal",
"font-style": "normal",
"position": "absolute",
"overflow": "hidden",
"font-family": "Arial",
"border-style": "solid",
"display": "block",
"background-color": "#3385D6",
"text-align": "center"
},
"imgurl": {
"font-size": "14px",
"line-height": "18px",
"color": "blue",
"border-width": "0px",
"letter-spacing": "0px",
"text-decoration": "none",
"height": "227",
"width": 200,
"border-color": "white",
"font-weight": "normal",
"font-style": "normal",
"position": "absolute",
"overflow": "hidden",
"font-family": "Arial",
"border-style": "solid",
"display": "block",
"background-color": "#3385D6",
"text-align": "center",
"left": 0,
"top": 80
},
"desc": {
"font-size": "13px",
"line-height": "18px",
"color": "blue",
"border-width": "0px",
"letter-spacing": "0px",
"text-decoration": "none",
"height": "69",
"width": "200px",
"border-color": "white",
"font-weight": "normal",
"font-style": "normal",
"position": "absolute",
"overflow": "auto",
"font-family": "Arial",
"border-style": "solid",
"display": "block",
"background-color": "#3385D6",
"text-align": "center",
"left": 0,
"top": 307
}
}
}
我把它放在css变量中。我想把字典像
elemorder=css['elemorder']
container=css['container']
但我得到错误字符串索引必须是整数,而不是 str如何创建两个变量(字典)elemorder 和容器?