Aug-12-2022, 02:08 PM
(This post was last modified: Aug-13-2022, 08:31 AM by buran.
Edit Reason: Added code tags
)
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
}
Gribouillis write Aug-12-2022, 02:49 PM:
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Please post all code, output and errors (it it's entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.