Aug-12-2022, 02:08 PM
I am having the hardest time getting anything to work in python. I am not very familiar with it. I know c# fairly well. I am trying to open a json file and print a specific element from it. Nothing too difficult. Reguardless of what I do or which example I use I always get some error. I do not get it. I have vscode set up exactlty as the example. I copy and paste the code. I renamed my file to be the file name in the example. I keep getting an error about the json file needs to be a string. I get 2 different errors it depends on if I use json.load or json.loads. Any guidance would be appreciated. Below is the very simple code I found and link.
https://www.anycodings.com/1questions/53...ith-python
https://www.anycodings.com/1questions/53...ith-python
import json from operator import itemgetter import os with open('file.json', 'r') as f: data = json.load(f) if data['inbound'] == 'true': print(data['url'])this is an example of the json data
Output: {
"date": "2021-06-14",
"url": "https://liveupdate.symantec.com",
"description": "Agent Installation Package",
"inbound": false,
"outbound": true
}