(Feb-20-2020, 11:20 AM)jk91 Wrote: how should i make it according to my case also i just have eclispse software installed on my systemUse PyDev
PyDev Wrote:PyDev is a Python IDE for Eclipse
(Feb-20-2020, 11:20 AM)jk91 Wrote: i also tried to execute above code in colab but again it ended in error:-You shall not use it like this,i do it in two parts read file then doing some test in interactive interpreter
>>>
.The task will be hard without any basic knowledge of Python.
Here is what's in
data.json
test file.Output:{
"firstName": "Jane",
"lastName": "Doe",
"hobbies": [
"running",
"sky diving",
"singing"
],
"age": 35,
"children": [
{
"firstName": "Alice",
"age": 6
},
{
"firstName": "Bob",
"age": 8
}
]
}
# test_read.py import json from pprint import pprint with open("data.json", "r") as read_file: data = json.load(read_file) pprint(data)
Output:{'age': 35,
'children': [{'age': 6, 'firstName': 'Alice'}, {'age': 8, 'firstName': 'Bob'}],
'firstName': 'Jane',
'hobbies': ['running', 'sky diving', 'singing'],
'lastName': 'Doe'}
So now reading as a script test_read.py
and run it,and i have to print the content.Doing test in interactive interpreter
>>>
,i do not need print.>>> data {'age': 35, 'children': [{'age': 6, 'firstName': 'Alice'}, {'age': 8, 'firstName': 'Bob'}], 'firstName': 'Jane', 'hobbies': ['running', 'sky diving', 'singing'], 'lastName': 'Doe'} >>> >>> data['hobbies'] ['running', 'sky diving', 'singing'] >>> ', '.join(data['hobbies']) 'running, sky diving, singing' # Can also use print here >>> print(', '.join(data['hobbies'])) running, sky diving, singing >>>