BeautifulSoup从变量中提取json为不带TAG的字符串

时间:2019-02-22 18:10:08

标签: python beautifulsoup

以下是我从javascript收到的响应。我在寻找json string like ['stocks']['counter']。如何删除变量定义var stockData = 'string'

var stockData = {
"Stocks":
[
  {
    "counter": "ALAM",
    "open": "0.100",
    "high": "0.105",
    "low": "0.100",
    "lastdone": "0.105",
    "change": "0.005",
    "volume": "8,033",
    "percentchange": "5.00",
    "stockcode": "5115"
  }
]
};

谢谢 萨尔瓦(Sarwar)

1 个答案:

答案 0 :(得分:0)

您忘记了字典索引

stockData['Stocks'][0]['counter']