马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
import requests
import json
UA = UA = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36'}
url = 'https://movie.douban.com/j/chart/top_list' # ?type=20&interval_id=100%3A90&action=&start=40&limit=20
data = {
"type":"20",
"interval_id":"100:90",
"action":"",
"start":"0",
"limit":"20"
}
r1 = requests.get(url,data,headers=UA).text
d1 = json.loads(r1)
print(d1)
我有一个json解析出来的数据,需要把两边的中括号取消就能变成一个字典了,请问有什么方法可以取消开始和结尾的中括号吗?
中括号是列表 for 循环就可以取出呗:
import requests
import json
UA = UA = {'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.92 Safari/537.36'}
url = 'https://movie.douban.com/j/chart/top_list' # ?type=20&interval_id=100%3A90&action=&start=40&limit=20
data = {
"type":"20",
"interval_id":"100:90",
"action":"",
"start":"0",
"limit":"20"
}
r1 = requests.get(url,data,headers=UA).text
d1 = json.loads(r1)
for i in d1:
print(i)
|