#๐ why cant i retrive the data from this json file?
37 messages ยท Page 1 of 1 (latest)
@serene pond
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
this is what im doing
print(a['jsondata'])
im trying to get this part of the json file
{"localized_subtitle":[null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null]
but when i do print(a['jsondata']['localized_subtitle]) it just gives me the error TypeError: string indices must be integers, not 'str'
why cant i retrive the data from this json file?
I'm assuming your Discord bot will be showing these updates correct?
You know Valorant has an official Discord and you can subscribe to be notified of updates?
no its not for valorant
im just trying to get the json data
that i collected
but i cant
print(repr(a['jsondata']))
it's possible the jsondata is not actually a dictionary, but just a string, that needs to be parsed using the json module
the "null" should be a strong indicator for that, as "null" doesn't exist in python (null in json get converted to None in python if you parse it using the json module)
no
literally as I showed it
the repr() is just there to show you that you got a string
and not a dictionary
and how would i get the dictionary?
!e
some_data = '{"foo": [null,null,null]}'
print(some_data)
print(repr(some_data))
@pseudo herald :white_check_mark: Your 3.12 eval job has completed with return code 0.
001 | {"foo": [null,null,null]}
002 | '{"foo": [null,null,null]}'
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.