http://www.learnpython.org/en/Modules_and_Packages
Monday, December 5, 2016
Packages for Python
Check out the full list of built-in modules in the Python standard library:
https://docs.python.org/2/library/
Source: http://www.learnpython.org/en/Modules_and_Packages
To import a module, we use the
import command. Parsing values from Json
12/5/16
http://stackoverflow.com/questions/2835559/parsing-values-from-a-json-file-in-python
http://stackoverflow.com/questions/2835559/parsing-values-from-a-json-file-in-python
[] are for lists, {} are for dictionaries.
Here's how your JSON file should look:
{
"maps": [
{
"id": "blabla",
"iscategorical": "0"
},
{
"id": "blabla",
"iscategorical": "0"
}
],
"masks": {
"id": "valore"
},
"om_points": "value",
"parameters": {
"id": "valore"
}
}
Then you can use your code:
import json
from pprint import pprint
with open('data.json') as data_file:
data = json.load(data_file)
pprint(data)
- With data, you can now also find values like so:
data["maps"][0]["id"] ...... here [0] because maps has values in [..]. If [0] not used it will throw string - int error.
data["masks"]["id"]
data["om_points"]
- How I can get the number of elements in node of JSON data?
down voteaccepted |
Convert it in dict.
|
Tuesday, November 29, 2016
Python installations
http://www.pydev.org/manual_101_install.html
https://www.python.org/downloads/release/python-352/
http://www.jetbrains.com/pycharm/download/download-thanks.html?platform=windows&code=PCC
this is the editor
first one is python (like
java)
2nd one is like escaplase
editor
In detail:
- Install windows version of python interpreter from the link https://www.python.org/downloads/release/python-352/
- Now after Interpreter is installed, you need editor or IDE to write python scripts. For this you can use "Pycharm" or "pydev" or you could also use just putty( or command prompt).
Link for pycharm: http://www.jetbrains.com/pycharm/download/download-thanks.html?platform=windows&code=PCC
pydev is the eclipse addin.
Link to pydev: http://www.pydev.org/manual_101_install.html
Wow. Huge improvements
Subscribe to:
Posts (Atom)
Wow. pydev is really good. Pycharm has lots of added value features like managing the python interpreter modules etc, but for coding and debugging pydev is good. It seems so much slicker now, good inspections, debugging, code completion.