['{"title": "1685436581", "expected_live_time": 1685436581}', '{"title": "1685440581", "expected_live_time": 1685440581}', '{"title": "1685444581", "expected_live_time": 1685444581}', '{"title": "1685448581", "expected_live_time": 1685448581}', '{"title": "1685452581", "expected_live_time": 1685452581}', '{"title": "1685456581", "expected_live_time": 1685456581}', '{"title": "1685460581", "expected_live_time": 1685460581}', '{"title": "1685464581", "expected_live_time": 1685464581}', '{"title": "1685468581", "expected_live_time": 1685468581}', '{"title": "1685472581", "expected_live_time": 1685472581}']把这个列表里面的每个字典外的引号去掉
时间: 2023-07-02 13:22:42 浏览: 76
可以使用以下代码实现:
```python
import json
lst = ['{"title": "1685436581", "expected_live_time": 1685436581}', '{"title": "1685440581", "expected_live_time": 1685440581}', '{"title": "1685444581", "expected_live_time": 1685444581}', '{"title": "1685448581", "expected_live_time": 1685448581}', '{"title": "1685452581", "expected_live_time": 1685452581}', '{"title": "1685456581", "expected_live_time": 1685456581}', '{"title": "1685460581", "expected_live_time": 1685460581}', '{"title": "1685464581", "expected_live_time": 1685464581}', '{"title": "1685468581", "expected_live_time": 1685468581}', '{"title": "1685472581", "expected_live_time": 1685472581}']
result = []
for item in lst:
data = json.loads(item)
result.append(data)
print(result)
```
输出结果如下:
```
[{'title': '1685436581', 'expected_live_time': 1685436581}, {'title': '1685440581', 'expected_live_time': 1685440581}, {'title': '1685444581', 'expected_live_time': 1685444581}, {'title': '1685448581', 'expected_live_time': 1685448581}, {'title': '16...```
其中,`json.loads()` 方法可以将 JSON 格式的字符串转换为 Python 对象,`result` 则是一个包含了所有字典的列表。
阅读全文