私はこのjsonからすべてのlattitudesとlongtitudesを取得しようとします。TypeError:リストのインデックスは、jsonからstr-getではなく整数またはスライスでなければなりません
コード:
import urllib.parse
import requests
raw_json = 'http://live.ksmobile.net/live/getreplayvideos?userid='
print()
userid = 735890904669618176
#userid = input('UserID: ')
url = raw_json + urllib.parse.urlencode({'userid=': userid}) + '&page_size=1000'
print(url)
json_data = requests.get(url).json()
print()
for coordinates in json_data['data']['video_info']:
print(coordinates['lat'], coordinates['lnt'])
print()
エラー:私は間違って行くん
/usr/bin/python3.6 /media/anon/3D0B8DD536C9574F/PythonProjects/getLocation/getCoordinates
http://live.ksmobile.net/live/getreplayvideos?userid=userid%3D=735890904669618176&page_size=1000
Traceback (most recent call last):
File "/media/anon/3D0B8DD536C9574F/PythonProjects/getLocation/getCoordinates", line 17, in <module>
for coordinates in json_data['data']['video_info']:
TypeError: list indices must be integers or slices, not str
Process finished with exit code 1
?
事前に、ご協力いただきありがとうございます。
jsonの一部を投稿して、その外観を表示します。 JSONは次のようになります。
{
"status": "200",
"msg": "",
"data": {
"time": "1499275646",
"video_info": [
{
"vid": "14992026438883533757",
"watchnumber": "38",
"topicid": "0",
"topic": "",
"vtime": "1499202678",
"title": "happy 4th of july",
"userid": "735890904669618176",
"online": "0",
"addr": "",
"isaddr": "2",
"lnt": "-80.1282576",
"lat": "26.2810628",
"area": "A_US",
"countryCode": "US",
"chatSystem": "1",
},
全JSON:https://pastebin.com/qJywTqa1
をBE-必要があります。したがって、最初の '[]'引数はスライスまたは整数である必要があります... –
...またはそれはdictですが、そのコンポーネントはありません。私はこれが事実だと信じています。 –
あなたのデータに関する情報がなければ、言うことは難しいです。ここにあなたのjsonデータを投稿してください。 –