['{"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 17:22:42 浏览: 39
可以使用以下代码实现:
```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` 则是一个包含了所有字典的列表。
相关推荐
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)